Comments (12)
I actually like that hoverIntent fails in the same way as "hover" and I feel like this should be a defect submitted against every browser in the world! :) This isn't hubris, it's just one of my pet peeves when scrolling on the internet (needing to find a happy swim lane for my cursor while scrolling).
I would argue that option (A) is more consistent with hoverIntent and how scrolling currently breaks everything. But I like option (B) more. Scrolling should block hoverIntent from calling handlerIn.
However, if the user were to stop scrolling and the cursor was resting over an item with hoverIntent, I think it should call handlerIn.
from jquery-hoverintent.
Does the same behavior happen when using .hover()
?
from jquery-hoverintent.
@usmonster yes, of course.
from jquery-hoverintent.
Sorry, I wasn't sure if this was a bug report or feature request. :] Are you saying the hover events should not be triggered on window scroll but are? Or that they should be triggered but aren't? Can you give an example?
from jquery-hoverintent.
This should probably be a feature request.
You can see an example here: http://jsfiddle.net/jhiggins/tE4KD/
Place your mouse in the circle, and use a mouse wheel or trackpad to scroll vertically over and past the blue block. The hover events are triggered, since this script is only looking at mouse movements.
A good use of this would be to avoid painting with hover events while using something like infinite scroll.
Thanks!
from jquery-hoverintent.
Ah, I see, so if I understand correctly the feature request would be something like "change behavior (or add an option) to suppress mouse tracking when scrolling and mouse isn't actually moving" ? In other words, conditionally use event.clientX
/clientY
instead of (or in addition to) pageX
/pageY
?
from jquery-hoverintent.
I believe in most cases the current behavior is desired, but a new option for this would be useful in situations. @jhiggins-thrillist or @usmonster are you planning on submitting a pull request?
from jquery-hoverintent.
I probably won't for this one, as I don't think I'd have the resources to adequately test it. I can imagine weird things happening for certain edge cases. Still, if others would want to test a version of it, I can quickly make a fork.
from jquery-hoverintent.
Whoops, please ignore the accidental reference to issue # 11, but I forked and roughly implemented what I think @jhiggins-thrillist was requesting. Please check it out, maybe test it if you want: here.
from jquery-hoverintent.
Updated code (should actually work now) and plugged it into @jhiggins-thrillist's fiddle: http://jsfiddle.net/tE4KD/7/
Still a proof-of-concept, but I think it addresses the issue. Depending on expected behavior, though, the if (scrolling) { return; }
could be moved elsewhere in the logic--e.g., if the mouse pointer is over a hoverIntented element when scrolling stops, one might want mousemove (instead of mouseenter) to trigger handlerIn.. Up for discussion.
from jquery-hoverintent.
I agree the behavior you define would in most cases be desired, but it might be tricky to implement. You'll have to account for the little amount the user could move the mouse during scrolling; the mouse is most likely moving even during scrolling.
from jquery-hoverintent.
Actually, the trickiest part of this is that there's currently a bug/browser inconsistency on WebKit/Blink browsers that would make implementing such behavior require a bit more code to work--please star the issue so it gets more attention!
It's still doable, though, and I can even reuse the same compare
logic (maybe with a tiny modification) to detect mousemove intent during scrolling. Otherwise I could add a similar function to detect when scrolling is stopped and only then trigger handlerIn after the next mousemove.
Which approach/behavior seems best? (A) Detecting mouse velocity during scrolling (based on cfg.sensitivity
and compare
logic) and only triggering handlerIn
after a certain post-scrollstart distance is reached, or (B) "pausing" hoverIntent behavior altogether until I've detected scrolling has stopped?
(Personally, I think option (B) would be more intuitive.)
from jquery-hoverintent.
Related Issues (20)
- create gh-pages branch, change official site to github.io HOT 7
- Check over/out methods gracefully. HOT 5
- make new version HOT 1
- Namespaces, unbinding and the .on() syntax HOT 7
- Add an minified version HOT 1
- Late firing on mobiles HOT 7
- Timeout only applys to mouseout method and doesn't affect mouseenter HOT 4
- Is it work with dynamically added element? HOT 3
- cdnjs issue was opened HOT 1
- remove bower.json
- 1.8.1 on NPM is a mismatch? HOT 7
- Disabled button not firing "over" (in a very specific circumstance) HOT 2
- handlerOut not triggered when domElement is removed dynamically HOT 3
- Improperly triggers mouseout when hovering a child inputs auto complete suggestion. HOT 3
- Possible bug HOT 3
- Deprecated jQuery HOT 1
- how to import like/in es6 modules? HOT 1
- ES6 version
- Typescript types needed HOT 1
- Failed to open stream HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-hoverintent.