Hey GSAP!
We're working on rebuilding our website using Vue and GSAP (love the framework <3) and I've stumbled onto an issue.
I feel a little dumb having to ask for help regarding this but I'd like to get over it!
I have a vertical full screen nav that when hovered, opens up a sidenav area with sub-items. The issue I'm stuck on is that I'd like the submenu to stay open when it is hovered so users can click on the sub-items. I've tried a number of approaches but nothing seemed to work, so I'd like to ask you guys for help!
I've tried changing the event handler to
//create the event handler
$(el)
.on("mouseenter", function () {
//this.style.willChange = 'transform';
this.animation.play();
});
$(".subnav").on("mouseleave", function () {
//this.style.willChange = 'auto';
this.animation.reverse();
});
or
//create the event handler
$(el)
.on("mouseenter", function () {
//this.style.willChange = 'transform';
this.animation.play();
});
$(".sub-item").on("mouseleave", function () {
//this.style.willChange = 'auto';
this.animation.reverse();
});
Attaching codepen url with a simple version for reference.
Thank you in advance!
EDIT: this seems to be working but its behaving very inconsistently, sometimes not working as expected while other times it works fine.
$(el)
.on("mouseenter", function () {
//this.style.willChange = 'transform';
this.animation.play();
}).on("mouseleave", function () {
//this.style.willChange = 'auto';
this.animation.paused() ? this.animation.play() : this.animation.reverse();
});
$(".sub-item")
.on("mouseenter", function () {
el.animation.play();
})
.on("mouseleave", function () {
el.animation.paused() ? el.animation.play() : el.animation.reverse();
});
EDIT2: I added console logs on the event and it looks like the sub-item hover triggers three times both on enter and leave. It does seem to be working the way I need it to at the moment, but again the behaviour seems inconsistent and sometimes the sub menu will not close when hovering out or over another menu item.