Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery disable and enable scrolling

Tags:

jquery

scroll

$('.news-wrap').mouseenter(function(event) {
    $(window).mousewheel(function(event) {
        event.preventDefault();
    });
});

Window scrolling is disabled, each I leave the element. How can I enable scrolling with mouseleave event?

like image 592
Taras Kudrych Avatar asked May 23 '12 00:05

Taras Kudrych


1 Answers

I've written a jQuery plugin to handle this: $.disablescroll.

It stops scrolling from mousewheel, touchmove, and buttons such as Page Down.

$('.news-wrap').mouseenter(function() {

    $(window).disablescroll();

}).mouseleave(function() {

    $(window).disablescroll("undo");

});

Hope someone finds this helpful.

like image 98
Josh Harrison Avatar answered Nov 13 '22 10:11

Josh Harrison