Skip to content

Commit

Permalink
fix anchor links
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Coulson committed Feb 29, 2024
1 parent b2cc6f4 commit b38cf01
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/story/story-content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ const activeChapterIndex = ref(-1);
onMounted(() => {
const hash = route?.hash.substring(1);
if (hash) {
const decodedHash = decodeURIComponent(hash);
const el = document.getElementById(decodedHash);
el?.scrollIntoView({ behavior: 'smooth' });
// Wait for a short period of time and then jump to the anchor.
setTimeout(() => {
const decodedHash = decodeURIComponent(hash);
const el = document.getElementById(decodedHash);
el?.scrollIntoView();
}, 200);
}
});
Expand Down

0 comments on commit b38cf01

Please sign in to comment.