How to make the top smoothly apply when scrolling down? now it's delayed. The logic is as follows: when scrolling 1px, the block moves down 10px.
When scrolling 1px, the .q2 block is shifted by 10px. That is, when scrolling by 4 px, the .q2 block is shifted by 40px
$(window).scroll(function(){ if($(window).scrollTop() > $(window).scrollTop()-1){ $('.q2').animate({ top: "+=10" });} }); body{ height: 1000px; } .q1{ height: 200px; border: 1px black solid; position: relative; } .q2 { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: gray; transition: all 1s; overflow: hidden; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="q1"> <div class="q2">465645<br> 465645<br> 465645<br> 465645<br> 465645<br> 465645<br> 465645<br> 465645<br> 465645<br> <span>465645</span><br> </div> </div>
if($(window).scrollTop() > $(window).scrollTop()-1)- Raz Galstyanif(x > x-1)- Raz Galstyan