I have a scroll animation which is working in a 'test' page: https://wordpress-899937-3173615.cloudwaysapps.com/test/
The problem is I cannot make it work on the final page because the height of the page is different and the animation starts much earlier than the expected.
var scroll = document.querySelector ('.curve');
window.addEventListener ('scroll', function(){
var value = 1 + window.scrollY / -200;
scroll.style.transform = `scaleY(${value})`;
})
{
margin:0;
padding:0;
}
body {
height:200vh;
background-color:#111;
}
section {
position:absolute;
width:100%;
height:100%;
background:#ff2;
}
section .curve {
position:absolute;
bottom:-200px;
height:200px;
width:100%;
transform-origin:top;
}
section .curve img{
width:100%;
height:100%;
<body>
<section>
<span class = "curve">
<img src = "https://wordpress-899937-3173615.cloudwaysapps.com/wp-content/uploads/2023/01/curve-white-300x59.png">
</span>
</section>
</body>
I need help improving the code to make it more 'responsive' to any page height.
How can trigger the animation from 100% to 0% of the viewport?