Explorar el Código

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 hace 8 años
padre
commit
8aa46a0d7e
Se han modificado 1 ficheros con 2 adiciones y 0 borrados
  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) {
     if (this.buttonRef) {
       this.scrollableParent = DomUtils.getScrollableParent(this.buttonRef)
       this.scrollableParent = DomUtils.getScrollableParent(this.buttonRef)
       this.scrollableParent.addEventListener('scroll', this.handleScroll)
       this.scrollableParent.addEventListener('scroll', this.handleScroll)
+      window.addEventListener('resize', this.handleScroll)
       this.buttonRect = this.buttonRef.getBoundingClientRect()
       this.buttonRect = this.buttonRef.getBoundingClientRect()
     }
     }
   }
   }
@@ -162,6 +163,7 @@ class Dropdown extends React.Component<Props, State> {
 
 
   componentWillUnmount() {
   componentWillUnmount() {
     window.removeEventListener('mousedown', this.handlePageClick, false)
     window.removeEventListener('mousedown', this.handlePageClick, false)
+    window.removeEventListener('resize', this.handleScroll, false)
     this.scrollableParent.removeEventListener('scroll', this.handleScroll, false)
     this.scrollableParent.removeEventListener('scroll', this.handleScroll, false)
   }
   }