Skip to content

Commit f01ce23

Browse files
nburlettrigor789
authored andcommitted
fix: calculation for {force: false, offset: nonZero} (#139)
Undo the pre-applied offset when calculating whether the element is already visible (and therefore we shouldn't scroll). Fixes #138
1 parent cbe0c1a commit f01ce23

File tree

2 files changed

+1
-511
lines changed

2 files changed

+1
-511
lines changed

src/scrollTo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export const scroller = () => {
196196
: container.offsetHeight;
197197
const containerTop = initialY;
198198
const containerBottom = containerTop + containerHeight;
199-
const elementTop = targetY;
199+
const elementTop = targetY - offset;
200200
const elementBottom = elementTop + element.offsetHeight;
201201
if (
202202
elementTop >= containerTop &&

0 commit comments

Comments
 (0)