How to disable scrolling until animation is complete?

半城伤御伤魂 提交于 2019-11-30 11:44:21
Barlas Apaydin

Thats a jQuery bug when you use animate with scrolling, good detection.

I did a research how to turn it off scrolling and find this question : How to disable scrolling temporarily?

Here is jsFiddle. You will see after click; user cant scroll untill animate complete.

$('.myDiv').click(function(){

    disable_scroll();

    $('html, body').stop().animate({ scrollTop: 0 }, 700,function() {
        enable_scroll();
    });
});

edit: thanks to galambalazs btw.

Avi Pinto

an idea - try hooking to the scroll event and use http://api.jquery.com/stop/ to stop your animation .. bad idea..

same problem with a solution - let user scrolling stop jquery animation of scrolltop?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!