$('.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?
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 this?
$('#abs').bind('mousewheel DOMMouseScroll', function(e) {
var scrollTo = null;
if (e.type == 'mousewheel') {
scrollTo = (e.originalEvent.wheelDelta * -1);
} else if (e.type == 'DOMMouseScroll') {
scrollTo = 1000 * e.originalEvent.detail;
}
if (scrollTo) {
e.preventDefault();
$(this).scrollTop(scrollTo + $(this).scrollTop());
}
});
I am currently using a plugin on bootstrap tour and the goal was to Disable scroll when clicking a link and enable it when you clicked an 'end tour' button in the tour.
In HTML create the div link by an id:
<div id='placeholder'><a href='#'>Placeholder link</a> </div>
Instantiate jquery with a click function.
start jquery:
$(document).ready(function() {
/*click Function*/
$('#placeholder').click(function(){
/*Disables scrolling*/
$('body').css('scroll', function(){
window.scrollTo(0,0);
});
});
});
Plugin option bootstrap tour when you end the popover:
/*This fire when clicking End Tour & placeholder would only work if that what you named the tour.*/
onEnd: function(placeholder) {
/*Enable scroling*/
$('body').css({ 'overflow': 'scroll' });
$(document).off('scroll');
}