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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章