personal-site/scripts/v2.js

33 lines
900 B
JavaScript
Raw Normal View History

2021-06-04 06:56:31 +00:00
const translate = document.querySelectorAll(".translate");
var watermark = document.querySelector(".hero-watermark");
2021-06-04 20:11:31 +00:00
//var skewedBg = document.querySelector(".skewed-bg");
2021-06-04 06:56:31 +00:00
window.addEventListener("scroll", () => {
var scroll = window.pageYOffset;
2021-06-04 20:11:31 +00:00
2021-06-04 06:56:31 +00:00
translate.forEach(element => {
let speed = element.dataset.speed;
element.style.transform = "translateY(" + (scroll * speed) + "px)";
});
2021-06-04 20:11:31 +00:00
// skewedBg.style.transform = "translateY(" + (scroll * skewedBg.dataset.speed) + "px) skewY(-3deg)";
watermark.style.transform = "translateY(" + (scroll * watermark.dataset.speed) + "px) translateX(-50%)";
2021-06-05 15:11:16 +00:00
});
//window.scrollBy({
// top: -100,
// behavior: "smooth"
//});
window.addEventListener("load", () => {
document.getElementById("skewed-bg").classList.add("skewed-bg");
document.getElementById("preloader").className = "preloader";
2021-06-04 06:56:31 +00:00
});