caaard/assets/parallax.js
2022-12-20 13:30:02 +00:00

10 lines
384 B
JavaScript

(function() {
var background = document.getElementById('background');
window.addEventListener('mousemove', function (event) {
var newX = (event.clientX / document.body.clientWidth * 2 - 1);
var newY = (event.clientY / document.body.clientHeight * 2 - 1);
background.style.top = -newY + "vh";
background.style.left = -newX + "vw";
})
})();