Skip to content

Commit

Permalink
prevent parallax scroll for links
Browse files Browse the repository at this point in the history
  • Loading branch information
jinkang-0 committed Jan 17, 2024
1 parent b14d921 commit 1dacae8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/Hero.astro
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,15 @@ import Brand from './Brand.astro';
}
</style>

<script>
<script lang="js">
const heroParallax = document.querySelector('.parallax-container');

window.addEventListener('scroll', () => {
if (heroParallax) heroParallax.scrollTop = window.scrollY / 4;
window.addEventListener('scroll', (e) => {
if (e && e.target && e.target.location)
return;
if (heroParallax)
heroParallax.scrollTo({
top: window.scrollY / 4,
});
});
</script>

0 comments on commit 1dacae8

Please sign in to comment.