Skip to content

Commit

Permalink
add resize event for affix
Browse files Browse the repository at this point in the history
  • Loading branch information
sorrycc committed Aug 4, 2015
1 parent e79150e commit 968b640
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/affix/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ var Affix = React.createClass({

componentDidMount() {
this.scrollEvent = rcUtil.Dom.addEventListener(window, 'scroll', this.handleScroll);
this.resizeEvent = rcUtil.Dom.addEventListener(window, 'resize', this.handleScroll);
},

componentWillUnmount() {
if (this.scrollEvent) {
this.scrollEvent.remove();
}
if (this.resizeEvent) {
this.resizeEvent.remove();
}
},

render() {
Expand All @@ -96,4 +100,3 @@ var Affix = React.createClass({
});

module.exports = Affix;

0 comments on commit 968b640

Please sign in to comment.