From a57fc694edddc78755ffcc18738a6c326dd9ecb6 Mon Sep 17 00:00:00 2001 From: Jack Tomaszewski Date: Fri, 11 Jan 2019 14:48:35 +0000 Subject: [PATCH] Fix calculating bounds when sticky is in a custom and already scrolled scroll container --- src/react-sticky-state.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/react-sticky-state.js b/src/react-sticky-state.js index a6c85c2..7dfa11d 100644 --- a/src/react-sticky-state.js +++ b/src/react-sticky-state.js @@ -196,6 +196,9 @@ class ReactStickyState extends Component { var parentRect = getAbsolutBoundingRect(this.scrollTarget); offsetY = this.scroll.y; rect = addBounds(rect, parentRect); + rect.top += offsetY; + rect.bottom += offsetY; + restrict = parentRect; restrict.top = 0; restrict.height = this.scroll.scrollHeight || restrict.height;