Skip to content

Commit b466e6e

Browse files
committed
feat(StickyPlaceholder): resize on height updates
Issue: #18
1 parent 2904144 commit b466e6e

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

lib/StickyPlaceholder.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class StickyPlaceholder extends React.Component<IProps, IState> {
4444
}
4545

4646
static getDerivedStateFromProps(props: IProps, state: IState): IState | null {
47-
const { width, clientWidth } = props.dimensions;
48-
const nextClientSize = `width:${width},clientWidth:${clientWidth}`;
47+
const { width, height, clientWidth, clientHeight } = props.dimensions;
48+
const nextClientSize = `width:${width},clientWidth:${clientWidth},height:${height},clientHeight:${clientHeight}`;
4949
if (state.isRecalculating) {
5050
const stickyRect = props.stickyRef.current.getBoundingClientRect();
5151
return {
@@ -96,6 +96,7 @@ class StickyPlaceholder extends React.Component<IProps, IState> {
9696
}
9797
}
9898

99-
export default connectViewport({ omit: ['scroll'] })<IOwnProps>(
100-
StickyPlaceholder,
101-
);
99+
export default connectViewport({
100+
omit: ['scroll'],
101+
deferUpdateUntilIdle: true,
102+
})<IOwnProps>(StickyPlaceholder);

package-lock.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"typescript": "^3.1.3"
4949
},
5050
"dependencies": {
51-
"react-viewport-utils": "^1.4.0",
51+
"react-viewport-utils": "^1.5.0",
5252
"recompose": "^0.30.0"
5353
},
5454
"peerDependencies": {

0 commit comments

Comments
 (0)