【问题标题】:How do I stop the duration of the scrollTop如何停止 scrollTop 的持续时间
【发布时间】:2015-09-21 09:22:11
【问题描述】:

到目前为止,我现在拥有的指令运行良好,但并非每个页面的高度都相同,所以我想在它已经在底部时停止持续时间。

这是指令的代码:

function (scope, elem, attrs) {
        $(document).on('contentchanged', '#mainText',  function () {
            $("html, body").animate({
                scrollTop: 0
            }, 0),
            $("html, body").animate({
                scrollTop: $(window).height()
            }, 4000);
        });
    }

因此,例如在第一页,视图位于底部,它不能再往下走,当我转到稍微低一点的下一页时,它会连续向下滚动。

我的问题是如何阻止它滚动?

【问题讨论】:

    标签: jquery angularjs directive scrolltop


    【解决方案1】:
    .animate( properties [, duration] [, easing] [, complete] )
    

    所以你可以这样做:

    .animate( 
        {scrollTop:'300px'},
        300,
        swing,
        function(){ 
           alert(animation complete! - your custom code here!); 
           } 
        )
    

    这里是 jQuery .animate 函数 api 页面:http://api.jquery.com/animate/

    【讨论】:

      猜你喜欢
      • 2017-12-18
      • 1970-01-01
      • 1970-01-01
      • 2012-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-10
      相关资源
      最近更新 更多