From d0646678579af789b0666ecd7401f7e65418a71e Mon Sep 17 00:00:00 2001 From: jquense Date: Mon, 16 Nov 2015 14:29:38 -0500 Subject: [PATCH] [fixed] AutoAffix nnot passing width or updating --- src/AutoAffix.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/AutoAffix.js b/src/AutoAffix.js index 7c817145..b1403cc9 100644 --- a/src/AutoAffix.js +++ b/src/AutoAffix.js @@ -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() ); @@ -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()); } @@ -119,12 +133,12 @@ class AutoAffix extends React.Component {
{children}