Просмотр исходного кода

Add 'resize' event listener to list position

Instead of updating the list position only on 'scroll' event, it is now
updated on 'resize' event also.
Sergiu Miclea 8 лет назад
Родитель
Сommit
8aa46a0d7e
1 измененных файлов с 2 добавлено и 0 удалено
  1. 2 0
      src/components/molecules/Dropdown/index.jsx

+ 2 - 0
src/components/molecules/Dropdown/index.jsx

@@ -148,6 +148,7 @@ class Dropdown extends React.Component<Props, State> {
     if (this.buttonRef) {
       this.scrollableParent = DomUtils.getScrollableParent(this.buttonRef)
       this.scrollableParent.addEventListener('scroll', this.handleScroll)
+      window.addEventListener('resize', this.handleScroll)
       this.buttonRect = this.buttonRef.getBoundingClientRect()
     }
   }
@@ -162,6 +163,7 @@ class Dropdown extends React.Component<Props, State> {
 
   componentWillUnmount() {
     window.removeEventListener('mousedown', this.handlePageClick, false)
+    window.removeEventListener('resize', this.handleScroll, false)
     this.scrollableParent.removeEventListener('scroll', this.handleScroll, false)
   }