mirror of
https://github.com/godotengine/godot-website.git
synced 2025-12-31 09:48:43 +03:00
Fix the parallax effect animation frame binding (#495)
This commit is contained in:
@@ -189,20 +189,20 @@ description = "footer partial"
|
||||
const parallaxMinWidth = 768;
|
||||
const parallaxSpeed = 0.4;
|
||||
|
||||
const parallaxTick = (offsetY) => {
|
||||
const parallaxTick = () => {
|
||||
if (window.innerWidth > parallaxMinWidth) {
|
||||
parallaxImage.style.transform = `translateY(${offsetY * parallaxSpeed}px)`;
|
||||
parallaxImage.style.transform = `translateY(${window.pageYOffset * parallaxSpeed}px)`;
|
||||
} else {
|
||||
parallaxImage.style.transform = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("scroll", () => {
|
||||
requestAnimationFrame(parallaxTick(window.pageYOffset))
|
||||
window.requestAnimationFrame(parallaxTick)
|
||||
});
|
||||
|
||||
window.addEventListener("resize", () => {
|
||||
requestAnimationFrame(parallaxTick(window.pageYOffset))
|
||||
window.requestAnimationFrame(parallaxTick)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user