jQuery Animating Elements by Scrolling the page

前端 未结 2 685
南方客
南方客 2021-01-03 11:28

I\'m trying to create a animation by scrolling the page, something like this:

$(function() {
$(document).on(\'scroll\', function() {
    var top = $(document         


        
2条回答
  •  鱼传尺愫
    2021-01-03 11:55

    According to the small part of your code, I think you can found a relation between your top and left value :

    var top = $(document).scrollTop();   
    var left = 826 - Math.floor(top - 2200)/2;
    $('#seta2').stop().animate({left: left+"px"}, 300, "easeOutQuad" );
    

提交回复
热议问题