I am trying to make an animation where the text moves towards right on scroll but I want to keep the background static until the text moves from initial to final position.
jQuery(document).on('scroll', function(){
jQuery('h1').css("left", Math.max(100 - 0.2*window.scrollY, 1) + "vw");
})
.scrolling-text{
margin: 0;
padding: 0;
height: 100vw;
overflow-x: hidden;
}
h1{
margin: 0;
padding: 0;
font-family: sans-serif;
position: fixed;
top: 50%;
transform: translateY(-50%);
white-space: nowrap;
font-size: 100px;
left: 100vw;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="scrolling-text">
<h1>Moving Text on Scroll</h1>
</div>
Here is the code I referred to but the background moves while the text is moving.