Open Dan503 opened 8 years ago
querySelectorAll
returns a NodeList
which isn't a type handled internally. You would need to iterate through the list and apply hoverintent to each element respectively. i.e
var _hoverTriggers = document.querySelectorAll('.JS-navigator__trigger--hover');
Array.prototype.forEach.call(_hoverTriggers, function(el) {
hoverintent(el, hoverInFunc, hoverOutFunc);
});
It might be a good idea to support NodeList
though so I'll leave it open!
Yuk! XP
This issue drove me back to the jQuery version of the plugin. You need to support node list if you want to be able to compete with it.
1+ On this. Would def make a difference 👍
For what it's worth, it's not that hard to make hoverIntent work with querySelectorAll
:
const toggles = document.querySelectorAll('[data-dropdown-open]');
if (!toggles) return;
for (const toggle of toggles) {
hoverIntent(
toggle,
() => {
toggle.setAttribute('data-dropdown-open', 'true');
},
() => {
toggle.setAttribute('data-dropdown-open', 'false');
}
);
}
I have this code
And I am receiving this error:
The most common use for this plugin is triggering mega menus on navigation items. It doesn't make sense not supporting query selector all in this context.