Skip to content

Commit 39c8888

Browse files
authored
fix(coordinates): never return negative scroll positions (#28)
1 parent ca098c1 commit 39c8888

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,10 @@ export default (target: Element, options: Options): CustomScrollAction[] => {
381381
)
382382
}
383383

384-
// Apply scroll position offsets
385-
blockScroll += viewportY
386-
inlineScroll += viewportX
384+
// Apply scroll position offsets and ensure they are within bounds
385+
// @TODO add more test cases to cover this 100%
386+
blockScroll = Math.max(0, blockScroll + viewportY)
387+
inlineScroll = Math.max(0, inlineScroll + viewportX)
387388
} else {
388389
// Handle each scrolling frame that might exist between the target and the viewport
389390

0 commit comments

Comments
 (0)