Skip to content

Commit

Permalink
prevent parallax scroll for links (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinkang-0 authored Jan 17, 2024
1 parent 2756d8f commit 5e99a20
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 5e99a20

Please sign in to comment.