Skip to content

Commit

Permalink
fix: calculation for {force: false, offset: nonZero} (#139)
Browse files Browse the repository at this point in the history
Undo the pre-applied offset when calculating whether the element is already
visible (and therefore we shouldn't scroll).

Fixes #138
  • Loading branch information
nburlett authored and rigor789 committed Sep 10, 2019
1 parent cbe0c1a commit f01ce23
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 511 deletions.
2 changes: 1 addition & 1 deletion src/scrollTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const scroller = () => {
: container.offsetHeight;
const containerTop = initialY;
const containerBottom = containerTop + containerHeight;
const elementTop = targetY;
const elementTop = targetY - offset;
const elementBottom = elementTop + element.offsetHeight;
if (
elementTop >= containerTop &&
Expand Down
Loading

0 comments on commit f01ce23

Please sign in to comment.