Skip to content

Commit 84df18c

Browse files
committed
feat(*): do not update when components are disabled
This requires the next version of react-viewport-utils to be installed which includes a bugfix which is not published yet.
1 parent 426cc4a commit 84df18c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/Sticky.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ class Sticky extends React.PureComponent<IProps, IState> {
199199
{this.renderSticky}
200200
</StickyPlaceholder>
201201
<ObserveViewport
202+
disableScrollUpdates={disabled}
202203
disableDimensionsUpdates
203204
onUpdate={this.handleScrollUpdate}
204205
recalculateLayoutBeforeUpdate={this.recalculateLayoutBeforeUpdate}

lib/StickyScrollUp.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ class StickyScrollUp extends React.PureComponent<IProps, IState> {
100100
stickyOffset: null,
101101
};
102102

103+
componentDidUpdate(prevProps: IProps, prevState: IState) {
104+
if (
105+
this.props.updateStickyOffset &&
106+
prevProps.disabled !== this.props.disabled
107+
) {
108+
this.props.updateStickyOffset(
109+
this.props.disabled ? 0 : this.state.stickyOffset,
110+
);
111+
}
112+
}
113+
103114
getStickyStyles(stickyRect: IRect, scroll: IScroll) {
104115
const styles = calcPositionStyles(stickyRect, scroll, {
105116
offsetTop: this.props.defaultOffsetTop,
@@ -165,6 +176,7 @@ class StickyScrollUp extends React.PureComponent<IProps, IState> {
165176
{this.renderSticky}
166177
</StickyPlaceholder>
167178
<ObserveViewport
179+
disableScrollUpdates={disabled}
168180
disableDimensionsUpdates
169181
onUpdate={this.handleViewportUpdate}
170182
recalculateLayoutBeforeUpdate={this.recalculateLayoutBeforeUpdate}

0 commit comments

Comments
 (0)