Skip to content

Commit

Permalink
Always remove window resize event listener
Browse files Browse the repository at this point in the history
As eagle-eyed @jeffkole pointed out [0], we always want to remove this
event listener, even if the scrollableAncestor does not exist.

[0]: #20 (comment)
  • Loading branch information
lencioni committed Aug 17, 2015
1 parent ec5b866 commit 0443d22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Add event object and scope to onEnter/onLeave calls
- Allow React 0.14.0-beta peerDependency
- Always remove window resize event listener

## 1.0.1

Expand Down
6 changes: 3 additions & 3 deletions src/waypoint.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const Waypoint = React.createClass({
threshold: PropTypes.number,
},

_wasVisible: false,

/**
* @return {Object}
*/
Expand Down Expand Up @@ -46,10 +44,12 @@ const Waypoint = React.createClass({
//
// Cannot read property 'removeEventListener' of undefined
this.scrollableAncestor.removeEventListener('scroll', this._handleScroll);
window.removeEventListener('resize', this._handleScroll);
}
window.removeEventListener('resize', this._handleScroll);
},

_wasVisible: false,

/**
* Traverses up the DOM to find an ancestor container which has an overflow
* style that allows for scrolling.
Expand Down

0 comments on commit 0443d22

Please sign in to comment.