Jquery animate div

Hi I am using the jquery animation function to animate div content trying to move a div to -top. The problem is not able to stop the function, its movement in exteme top = -10px. I want to move it to the intervals that oncrolling it should go -10px from the existing height in the next interval again it should go to the next -10px while moving the scroll

+3
source share
2 answers

The problem is that you execute the code once, so go to -10px as soon as you need to execute this code again after a certain interval. You can do something like this:

$ (function () {setInterval (step 100);});

move() { $ ( "# mvup" ). animate ({ "top": "- = 10px" }, "slow" ); }

,

+1

, - , ?

(, ):

$(document).scroll(function()
{
  $('yourBox').animate({top: $(document).scrollTop() - 10});
});

, , .

window.onload = function()
{
  var frm = document.getElementById("from").contentWindow;
  frm.onscroll = function(){
    $("#mvup").animate({"top": "-=10px"}, "slow");
  }
}

:

  • jQuery $(document).ready(), window.onload = .... , .
  • jQuery $('#mvup').scroll(), frm.onscroll = ....

!

+1

Source: https://habr.com/ru/post/1776617/


All Articles