Jump to content
Search Community

Hover popup effect with delay, too late

acidking test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,
I am trying to create a popup over a button with a delay, the problem is if I hover out of the button before the delay is over, then the tween would still go on. I know I can kill the tween in Timeline, but I am not using timeline here because I am using a (this) call. Any suggestion would be appreciated.
 
    $('.button').on('mouseenter', function () {
        TweenLite.to($(this).children('.popup'), 0.2, { delay: 1, opacity: '1' });
    });
    $('.button').on('mouseleave', function () {
        TweenLite.to($(this).children('.popup'), 0, { opacity: '0' });
    });

 

Link to comment
Share on other sites

Hi

 

Why don't you try play() and reverse() on mouse over/out events.

 

Create the tween inside a variable and then call the methods on each event.

 

var t = TweenLite.to(element, time, {vars, paused:true}),

triggerEl = $("#triggerEl");

 

triggerEl.mouseover(function(){

t.play();

});

 

triggerEl.mouseout(function(){

t.reverse();

});

 

That shouldn't fire the animation if the mouse leaves the element before the delay time has elapsed.

 

Rodrigo.

  • Like 1
Link to comment
Share on other sites

All good ideas mentioned, and just so you know, you can kill all the tweens of a particular object anytime like:

TweenLite.killTweensOf(yourElement);

And if you want to get more precise, you can kill only the opacity tweens using the extra parameter, like:

TweenLite.killTweensOf(yourElement, false, {opacity:true});
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...