The issue I'm facing is that calling update changes the props for the instance, but does not seem to update the actual scroll behavior. Taking a look at the method:
|
update (updatedProps = null) { |
|
this.instances.forEach((instance) => { |
|
this.computeScrollOffsets(instance) |
|
if (updatedProps) { |
|
// eslint-disable-next-line no-unused-vars |
|
for (const updatedProp in updatedProps) { |
|
instance.props[updatedProp] = updatedProps[updatedProp] |
|
} |
|
} |
|
}) |
|
|
|
return this |
|
} |
I can see that computeScrollOffsets is called BEFORE the props are updated. It seems to me that computing scroll offsets ought to be done AFTER changing the props.
Manually calling computeScrollOffsets after using update in my own implementation results in the desired change to scroll behavior.
I'm happy to submit a PR to move computeScrollOffsets below prop changes if this logic seems correct.
Incidentally, I found the issue where this code was introduced (#412) - I suspect the problem I'm seeing is hidden by the example where update is called on resize, where update is probably called multiple times as the browser resize event fires multiple times (thus recomputing the previous prop updates, but never recomputing the very last prop update).
The issue I'm facing is that calling
updatechanges the props for the instance, but does not seem to update the actual scroll behavior. Taking a look at the method:stickybits/src/stickybits.js
Lines 443 to 455 in 6262797
I can see that
computeScrollOffsetsis called BEFORE the props are updated. It seems to me that computing scroll offsets ought to be done AFTER changing the props.Manually calling
computeScrollOffsetsafter usingupdatein my own implementation results in the desired change to scroll behavior.I'm happy to submit a PR to move
computeScrollOffsetsbelow prop changes if this logic seems correct.Incidentally, I found the issue where this code was introduced (#412) - I suspect the problem I'm seeing is hidden by the example where
updateis called onresize, whereupdateis probably called multiple times as the browser resize event fires multiple times (thus recomputing the previous prop updates, but never recomputing the very last prop update).