Skip to content

Commit

Permalink
fix(bug): fixes an issue where anchor scrolling could lead to the wro…
Browse files Browse the repository at this point in the history
…ng coordinates under some circumstances
  • Loading branch information
wessberg committed Feb 23, 2019
1 parent 84d2c9b commit 2f399f4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/patch/anchor/catch-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function catchNavigation(): void {
if (elementMatch == null) return;

// Find the nearest ancestor that can be scrolled
const [ancestorWithScrollBehavior, behavior] = findNearestAncestorsWithScrollBehavior(elementMatch);
const [, behavior] = findNearestAncestorsWithScrollBehavior(elementMatch);

// If the behavior isn't smooth, don't proceed
if (behavior !== "smooth") return;
Expand All @@ -42,10 +42,8 @@ export function catchNavigation(): void {
e.preventDefault();

// Now, scroll to the element with that ID
ancestorWithScrollBehavior.scrollTo({
behavior,
top: (elementMatch as HTMLElement).offsetTop,
left: (elementMatch as HTMLElement).offsetLeft
elementMatch.scrollIntoView({
behavior
});
});
}

0 comments on commit 2f399f4

Please sign in to comment.