jQuery滚动到页面底部锁定/口吃/抖动滚动

jQuery scroll to bottom of page locks/stutters/judders scroll

本文关键字:滚动 口吃 抖动 锁定 jQuery 底部      更新时间:2023-09-26

我试图在用户提交表单后滚动到页面底部。然而,当我执行以下代码时,浏览器滚动到页面底部,但不允许我在没有锁定/快门/抖动的情况下向上滚动(通过鼠标滚轮、滚动条或箭头键)。

var scrollToBottom = function() {
    $("html, body").animate({ scrollTop: $(document).height() - $(window).height()}, 0);
}

知道是什么引起的吗?它似乎在5秒后"放松"了对浏览器的控制。

我运行了你的函数,它没有将我锁定在底部5秒。默认情况下,它将在滚动时锁定,并在浏览器到达预定位置时释放您。

http://jsfiddle.net/oq9eo2zz/2/

其他东西可能导致这个问题,但如果你正在寻找一个快速的工作,你可以强迫它解锁(停止动画)在'mousewheel dommousescroroll keyup keydown'。

$(window).on("mousewheel DOMMouseScroll keyup keydown", function(e){
  $('html, body').stop();
});

0时间:http://jsfiddle.net/oq9eo2zz/1/

3000时间:http://jsfiddle.net/oq9eo2zz/4/

希望这对你有帮助!

Use This

var scrollToBottom = function() {
  $('html, body').animate({scrollTop:$(document).height()}, 'slow');
  return false;
}

function scrollToBottom()
{
  alert("Scrolling to bottom ...");
  window.scrollTo(0, document.body.scrollHeight);
}