Skip to content

Commit

Permalink
removes dependency on navigtion api
Browse files Browse the repository at this point in the history
  • Loading branch information
martrapp committed Dec 13, 2024
1 parent fe260c3 commit d1a91e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-numbers-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vtbag/cam-shaft': patch
---

Removes dependency on Navigation API
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ for (const c of config) {
newDuration.push(0);
}
}
addEventListener('pageswap', () => localStorage.setItem('vtbag-camshaft', '' + scrollY));
addEventListener('pageswap', (e) => {
localStorage.setItem('vtbagCamshaftScrollY', '' + scrollY);
localStorage.setItem('vtbagCamshaftNavigationType', e.activation?.navigationType);
});
addEventListener('pagereveal', async (e) => {
if (!e.viewTransition) return;
let newOffset = 0;

if (window.navigation && window.navigation?.activation.navigationType === 'traverse' || performance.navigation.type === 2) {
if (sessionStorage.getItem('vtbagCamshaftNavigationType') === 'traverse') {
newOffset = scrollY;
} else {
const hash = location.hash ?? '#top';
Expand Down

0 comments on commit d1a91e2

Please sign in to comment.