Closed meibegger closed 8 years ago
Mousewheel event detection is a good call. That should be simple to add.
I've been debating for a long time about using mousemove
because of the potential expense of an event that fires continually. Debouncing would obviously be necessary. Using mouseenter
was a concession, but you're right that it doesn't cover all use cases. I'm going to take a look at this later this week.
I forked what-input and added wheel & mousemove-support. Both with a debounce. (https://github.com/meibegger/what-input/blob/master/what-input.js) You could merge it if you want. I hope you don't mind!
This looks good! I have one comment and one question:
mousemove
, mouseenter
is no longer necessary so you can remove lines 47 and 202.mousewheel
binding to support more browsers. I was looking at this SitePoint article: http://www.sitepoint.com/html5-javascript-mouse-wheel/. What do you think?You are right! I removed mouseenter-detection.
According to MDN mousewheel
is deprecated (https://developer.mozilla.org/en-US/docs/Web/Events/wheel) and not very widely supported (https://developer.mozilla.org/en-US/docs/Web/Events/mousewheel#Browser_compatibility) ... ?
Yea, looks like https://developer.mozilla.org/en-US/docs/Web/Events/wheel is the way to go. The code block on that page is more robust than we need, but maybe there's something in this block for basic detection we can use:
support = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
"DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
done : )
Hi, do you want to merge our "fix" or do you want to provide a different solution, or what is the plan?
Hey @meibegger, sorry for the delay. I got buried under some project work over the past month but wanted to have time to test your fix before merging it in. I should be able to get to this in the next week.
Just published version 1.2.0 and rolled in some refactoring with the way mouse wheel is implemented.
Hey @ten1seven. Great!
Hi, if you use the keyboard and then scroll with the mouse-wheel or move the mouse without leaving the window, currently the mouse-input is not identified, which is inconsistent. So i think it might be useful to extend the mouse-identification by the wheel and mousemove events. What do you think? Should i extend your widget?