如何停止 scrollTop 的持续时间
How do I stop the duration of the scrollTop
我现在使用的指令到目前为止效果很好,但不是每个页面都有相同的高度所以我想在它已经在底部时停止持续时间。
这是指令的代码:
function (scope, elem, attrs) {
$(document).on('contentchanged', '#mainText', function () {
$("html, body").animate({
scrollTop: 0
}, 0),
$("html, body").animate({
scrollTop: $(window).height()
}, 4000);
});
}
例如,在第一页,视图位于底部,它不能再低了,当我转到下一页时,它会继续向下滚动。
我的问题是如何停止滚动?
.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/
我现在使用的指令到目前为止效果很好,但不是每个页面都有相同的高度所以我想在它已经在底部时停止持续时间。
这是指令的代码:
function (scope, elem, attrs) {
$(document).on('contentchanged', '#mainText', function () {
$("html, body").animate({
scrollTop: 0
}, 0),
$("html, body").animate({
scrollTop: $(window).height()
}, 4000);
});
}
例如,在第一页,视图位于底部,它不能再低了,当我转到下一页时,它会继续向下滚动。
我的问题是如何停止滚动?
.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/