Skip to content

Commit

Permalink
[fixed] AutoAffix nnot passing width or updating
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Nov 16, 2015
1 parent 39f1bf2 commit d064667
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/AutoAffix.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class AutoAffix extends React.Component {
this._windowScrollListener = addEventListener(
ownerWindow(this), 'scroll', () => this.onWindowScroll()
);

this._windowResizeListener = addEventListener(
ownerWindow(this), 'resize', () => this.onWindowResize()
);

this._documentClickListener = addEventListener(
ownerDocument(this), 'click', () => this.onDocumentClick()
);
Expand Down Expand Up @@ -59,12 +64,21 @@ class AutoAffix extends React.Component {
if (this._documentClickListener) {
this._documentClickListener.remove();
}
if (this._windowResizeListener){
this._windowResizeListener.remove();
}
}

onWindowScroll() {
this.onUpdate();
}

onWindowResize() {
if (this.props.autoWidth) {
requestAnimationFrame(() => this.onUpdate());
}
}

onDocumentClick() {
requestAnimationFrame(() => this.onUpdate());
}
Expand Down Expand Up @@ -119,12 +133,12 @@ class AutoAffix extends React.Component {
<div ref="positioner" />

<Affix
{...props}
offsetTop={effectiveOffsetTop}
viewportOffsetTop={viewportOffsetTop}
offsetBottom={offsetBottom}
affixStyle={affixStyle}
bottomStyle={bottomStyle}
{...props}
>
{children}
</Affix>
Expand Down

0 comments on commit d064667

Please sign in to comment.