Animate scrollTop无法在firefox中运行 - Animate scrollTop not working in firefox

问题:

This function works fine. 这个功能很好。 It scrolls the body to a desired container's offset 它将主体滚动到所需容器的偏移量

function scrolear(destino){
    var stop = $(destino).offset().top;
    var delay = 1000;
    $('body').animate({scrollTop: stop}, delay);
    return false;
}

But not in Firefox. 但不是在Firefox中。 Why? 为什么?

-EDIT- -编辑-

To handle de double trigger in the accepted answer, I suggest stoping the element before the animation: 要在接受的答案中处理de double触发器,我建议在动画之前停止元素:

$('body,html').stop(true,true).animate({scrollTop: stop}, delay);

解决方案:

参考一: https://en.stackoom.com/question/YBxz
参考二: https://stackoom.com/question/YBxz
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章