Reputation: 2929
Is it possible to allow click but not scroll events?
pointer-events: none;
Will disable both types of inputs, I would like to disable only scroll. Any other ideas for workarounds?
Upvotes: 8
Views: 9645
Reputation: 5387
Do it with javascript:
function noScroll(event) {
event = event || window.event;
if (event.preventDefault) {
event.preventDefault();
}
event.returnValue = false;
return false;
}
// disable scolling on the whole window:
if (!window.addEventListener) {
// old IE only
window.attachEvent("onscroll", noScroll);
} else {
// Firefox only
window.addEventListener("DOMMouseScroll", noScroll);
// anything else
window.addEventListener("scroll", noScroll);
}
// disable scrolling on a single element:
var el = document.getElementById("elementID");
if (!el.addEventListener) {
el.attachEvent("onscroll", noScroll);
} else {
el.addEventListener("DOMMouseScroll", noScroll);
el.addEventListener("scroll", noScroll);
}
That should do the trick.
Upvotes: -1
Reputation: 3895
Add this css:
.stopScroll{
height:100%;
overflow:hidden;
}
Then in jQuery:
$('body').addClass('stopScroll');
Look at the fiddle:https://jsfiddle.net/26dct8o3/1/
Would help if you are looking for this. Otherwise let me know in comments if this is not what you want.
Upvotes: 1