Skip to content

Commit d064667

Browse files
committed
[fixed] AutoAffix nnot passing width or updating
1 parent 39f1bf2 commit d064667

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/AutoAffix.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class AutoAffix extends React.Component {
3232
this._windowScrollListener = addEventListener(
3333
ownerWindow(this), 'scroll', () => this.onWindowScroll()
3434
);
35+
36+
this._windowResizeListener = addEventListener(
37+
ownerWindow(this), 'resize', () => this.onWindowResize()
38+
);
39+
3540
this._documentClickListener = addEventListener(
3641
ownerDocument(this), 'click', () => this.onDocumentClick()
3742
);
@@ -59,12 +64,21 @@ class AutoAffix extends React.Component {
5964
if (this._documentClickListener) {
6065
this._documentClickListener.remove();
6166
}
67+
if (this._windowResizeListener){
68+
this._windowResizeListener.remove();
69+
}
6270
}
6371

6472
onWindowScroll() {
6573
this.onUpdate();
6674
}
6775

76+
onWindowResize() {
77+
if (this.props.autoWidth) {
78+
requestAnimationFrame(() => this.onUpdate());
79+
}
80+
}
81+
6882
onDocumentClick() {
6983
requestAnimationFrame(() => this.onUpdate());
7084
}
@@ -119,12 +133,12 @@ class AutoAffix extends React.Component {
119133
<div ref="positioner" />
120134

121135
<Affix
136+
{...props}
122137
offsetTop={effectiveOffsetTop}
123138
viewportOffsetTop={viewportOffsetTop}
124139
offsetBottom={offsetBottom}
125140
affixStyle={affixStyle}
126141
bottomStyle={bottomStyle}
127-
{...props}
128142
>
129143
{children}
130144
</Affix>

0 commit comments

Comments
 (0)