Javascript: Capture mouse wheel event and do not scroll the page?

You can do so by returning false at the end of your handler (OG). this.canvas.addEventListener(‘wheel’,function(event){ mouseController.wheel(event); return false; }, false); Or using event.preventDefault() this.canvas.addEventListener(‘wheel’,function(event){ mouseController.wheel(event); event.preventDefault(); }, false); Updated to use the wheel event as mousewheel deprecated for modern browser as pointed out in comments. The question was about preventing scrolling not providing the right … Read more

How can I differentiate a manual scroll (via mousewheel/scrollbar) from a Javascript/jQuery scroll?

Try this function: $(‘body,html’).bind(‘scroll mousedown wheel DOMMouseScroll mousewheel keyup’, function(e){ if ( e.which > 0 || e.type == “mousedown” || e.type == “mousewheel”){ $(“html,body”).stop(); } }) Also, did you see this tutorial? Update: Modern browsers now use “wheel” as the event, so I’ve included it in the code above.

How to direct the mouse wheel input to control under cursor instead of focused?

Scrolling origins An action with the mouse wheel results in a WM_MOUSEWHEEL message being sent: Sent to the focus window when the mouse wheel is rotated. The DefWindowProc function propagates the message to the window’s parent. There should be no internal forwarding of the message, since DefWindowProc propagates it up the parent chain until it … Read more

disable mouse wheel on itemscontrol in wpf

The answer you have referenced is exactly what is causing your problem, the ListBox (which is composed of among other things a ScrollViewer) inside your ScrollViewer catches the MouseWheel event and handles it, preventing it from bubbling and thus the ScrollViewer has no idea the event ever occurred. Use the following extremely simple ControlTemplate for … Read more

Mousewheel event in modern browsers

Clean and simple: window.addEventListener(“wheel”, event => console.info(event.deltaY)); Browsers may return different values for the delta (for instance, Chrome returns +120 (scroll up) or -120 (scroll down). A nice trick to normalize it is to extract its sign, effectively converting it to +1/-1: window.addEventListener(“wheel”, event => { const delta = Math.sign(event.deltaY); console.info(delta); }); Reference: MDN.