Skip to content

Commit

Permalink
[fix] parallax effect (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinkang-0 authored Jan 17, 2024
1 parent 5e99a20 commit 0d2807d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/components/Hero.astro
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,9 @@ import Brand from './Brand.astro';
<script lang="js">
const heroParallax = document.querySelector('.parallax-container');

window.addEventListener('scroll', (e) => {
if (e && e.target && e.target.location)
return;
if (heroParallax)
heroParallax.scrollTo({
top: window.scrollY / 4,
});
window.addEventListener('scroll', e => {
// hacky fix, but will suffice for now
if (e && e.target && e.target.location && e.target.location.hash) return;
if (heroParallax) heroParallax.scrollTop = window.scrollY / 4;
});
</script>

0 comments on commit 0d2807d

Please sign in to comment.