Преглед изворни кода

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 година
родитељ
комит
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)
   }