-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No delay between adjacent menu items #6
Comments
I cringe when someone references a specific implementation / use case. But I think it was appropriate to illustrate your point and overall I think this is a brilliant idea. I can see a new configuration property (called "sharedIntent") with the default value set to false. A value of false would result in identical functionality to current/previous releases, thus not breaking any existing implementation. When sharedIntent is set to true, a short timeout would be used to determine adjacency. That timeout would be triggered on mouse leave, and cleared on mouse enter. While the timeout is running, the intent-determining mouse move logic would be bypassed. Once the timeout's time is up, it'll reset the intent logic. |
You can also use |
Is there any chance of getting this feature in soon? I have been trying to modify it and use event.relatedTarget but am struggling with it. |
👍 brilliant |
@inquiztr Can you provide a jsfiddle or jsbin that simply demonstrates your issue when using |
Here is my attempt at it. It seems to work but the more i test it i see sometimes it misses triggering hovers sometimes: |
I took a look, and I think this is the behavior @Grimmrobe wants: http://jsfiddle.net/sk6L3dp4/3/ Though I'm not yet convinced the best way to do this is to build it into the plugin. Similarly to #9, I would recommend simply using In more concrete terms, here's a general pattern that could potentially be used for such cases: <elt>
<child />
<child />
<child />
</elt> And the JS: $('elt').hoverIntent(function(){ $(this).toggleClass('hoverActive'); });
function doThing(e){
if ( ! $(this).parent().hasClass('hoverActive') ) { console.log('nope!'); return; }
if ( e.type === 'mouseenter' ) { console.log('hovering on and doing a thing!'); }
else /* e.type === 'mouseleave' */ { console.log('hovering off and doing a different thing!'); }
}
$('elt child').hoverIntent({ interval: 0, over: doThing, out: doThing });
// or, using delegation:
//$('elt').hoverIntent({ interval: 0, over: doThing, out: doThing, selector: 'child' }); It's untested but probably produces the same desired effect, and without the need to add that specific new functionality to the plugin itself. Thoughts @briancherne, @inquiztr, et al.? |
Thanks @usmonster. I am a javascript novice and going through your jsfiddle you provided: http://jsfiddle.net/sk6L3dp4/3/ Could you explain your condition here, specifically I am not familiar with the !! in the condition: But it seems to be working great, and I am thinking of using it in my project. As for your other suggestion about adding hoverIntent to both the parent and children separately with different intervals is a pretty cool and elegant idea that I will try as well. But I am wondering, how would the initial "500ms"delay" happen. I would imagine as your mouse moves onto a child for the first time, the parent UL hover would be still in the delay, while the child hover triggers doThing right away.. but as the parent hasnt triggered yet, nothing would happen. |
Hi @inquiztr. Of course I'll explain. :] The As for how my double-hoverintent suggestion works, well.. it actually probably doesn't work. I haven't tested, but your concern is justified, as that's exactly what would happen. There's a missing part, and I haven't had a chance to think it through to the point where it's not messy. I will try to get back to you on that. |
@usmonster hi there! Is your fiddle ready for a PR by any chance? Many thanks! |
@frankie-loves-jesus No, I haven't worked towards that yet. I think there's still some discussion and reflection to be done, and I also haven't had time to think about the alternative approach. I'll update here when I have something, but I'm pretty certain there's a general pattern that could be used to achieve this same behavior with the current version of the plugin. |
+1 |
https://github.com/digital-chemist/dropdownMenus index2 uses css3 animation to open and close the menu and a callback of some sorts needs to be added so the menu "text" doesnt appear until the menu is fully open...but you get the point cheers, hope it helps |
Just had a chance to think about this again, and I came up with something a bit simpler but not far off from what I'd previously proposed above. The principle is exactly the same, but instead of using http://jsfiddle.net/sk6L3dp4/5/ As before, hoverIntent is used to toggle the active state of the parent, but it also re-triggers a Here's an even simpler version that doesn't need to explicitly track the currently-hovered child element, and which would work perfectly if only issue #11 were resolved (@briancherne, let me know if I can/should make a PR for that): Again, these are general patterns that nicely and simply handle the "shared intent" use case without the need to add any new functionality to hoverIntent. I'm still not convinced the whole Hope this helps! (Also, please let me know if I've missed anything..) |
This is mighty fine work @usmonster! I just wish @briancherne was around to enjoy it. |
Thanks, @frankie-loves-jesus. Brian's away from computers for a bit, he should be back online in a few weeks. |
A few weeks... more like a few months... 😕 @frankie-loves-jesus - Does resolving issue #11 resolve this issue using @usmonster's workaround above? Or do you still feel the need for an adjacency check? Re-reading my initial comment, I think the reason I was leaning towards |
There he is -- welcome back @briancherne! About the adjacency check, I think you meant to hit @Grimmrobe with that one? |
Just an idea.. when moving sideways across a horizontal navigation with many large submenus, It would be less jarring visually to have no delay between the over and out of each submenu.
In other words: hoverintent is useful on the first hover but once the cursor is in the menu there could be a setting to remove the delay ( and act like a normal hover ) between over and out based on if target has same class etc...
The text was updated successfully, but these errors were encountered: