Add parallax effect to background

This commit is contained in:
Tyler Perkins
2023-07-17 23:17:11 -04:00
parent 21d70b4a8a
commit b2f80c3a92
12 changed files with 155 additions and 32 deletions

View File

@@ -4,6 +4,13 @@ window.onload = function() {
document.querySelectorAll(".scramble").forEach(item => {
item.addEventListener("mouseover", scramble);
});
window.addEventListener('scroll', function() {
const parallax = document.querySelector('.parallax')
let scrollPosition = window.pageYOffset;
parallax.style.transform = 'translateY(' + scrollPosition * .5 + 'px)';
})
}
function scramble(event){