加载一个相当长的页面后,我需要平滑地向下滚动到页面上的某个页面,这样用户就不必这样做了。
$(document).ready(function () {
// Handler for .ready() called.
$('html, body').animate({
scrollTop: $('#today').offset().top
}, 'slow');
});
...
<div id="today">foo</div>
这在桌面浏览器中运行良好,但在iPhone上,特别是在Android上,它非常生涩。
问题:
答案 0 :(得分:1)
默认情况下,jQuery .animate()
easing
选项设置为swing
,尝试设置为linear
,例如,
$(document).ready(function () {
// Handler for .ready() called.
$('html, body').animate({
scrollTop: $('#today').offset().top
}, 2000, "linear");
});
#today {
position : absolute;
top : 1000px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="today">today</div>