Jump to content
Search Community

Alternatives to Mouse Out

ainsley_clark 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 all,

 

Very new to GSAP, but it seems like an excellent tool.

 

A very simple question, one which has probably been covered but I cant seem to find it.

Im animating a div class that has a name in it (.name).

I want some animation to occur when the user rolls over it (scaleup), at the moment I have a mouse out function but would much prefer for the name to expand and then go back to the original size using only a mouse over.

Basically I'm trying to rid of the mouseout function so it scales up, then down, without the userof timelineMax.

 

Many thanks in advance.

 

    $(document).ready(function(){
        $('.name').mouseover(function (e){   
            TweenMax.to($(this), .6, {
                scaleX: 1.2, 
                scaleY: 1.2, 
                ease:Elastic.easeOut
            });
        })
        $('.name').mouseout(function (e){   
            TweenMax.to($(this), .6, {
                scaleX: 1, 
                scaleY: 1, 
                ease:Elastic.easeOut
            });
        })
    });

 

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums,

 

If I understand correctly you can make the element return to its normal size without using a Timeline or a mouseout.

A single TweenMax tween can repeat and go back to where it started.

I used a separate yoyoEase for the return animation.

I am also using a repeatDelay so you can see where the forward animation ends and the repeat (yoyo) begins. You can remove the delay and yoyoEase if you like

 

$(".red").mouseover(function(element){
  TweenMax.to(this, 1, {scale:1.5, ease:Elastic.easeOut, yoyoEase:Power2.easeOut, repeat:1, repeatDelay:0.2})
})

 

 

See the Pen rZJyWy?editors=0010 by GreenSock (@GreenSock) on CodePen

 

 

 

  • Like 4
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...