Share Posted July 12, 2018 Hey, everybody! I have a problem I try to make a round grow if a mouse passes over but the animation is done directly I don't understand, doesn't GSAP work with Jquery? if ($(".scale").mouseover) { TweenMax.to(".scale", 1, { css: { scale: 2, backgroundColor: "#343434" } }); } else { TweenMax.to(".scale", 1, { css: { scale: 1 } }); } please help me Link to comment Share on other sites More sharing options...
Share Posted July 12, 2018 Your if statement will always be true. You might want to go check up on how jQuery hover works, and then make a demo if you can't get it working. https://api.jquery.com/hover/ Link to comment Share on other sites More sharing options...
Share Posted July 12, 2018 Hi @lucrampro, GSAP certainly works well with jQuery ... but it looks like you're using jQuery incorrectly (if I understand what you want to accomplish). It looks like you want to respond to mouseenter and mouseleave ... simply a hover event. $(".scale").hover( function(){ TweenMax.to( $(this), 1, { css: { scale: 2, backgroundColor: "#343434" } }); }, function(){ TweenMax.to( $(this), 1, { css: { scale: 1 } }); } ); EDIT: Sorry @OSUblake, didn't see that we were responding at the same time 2 Link to comment Share on other sites More sharing options...
Author Share Posted July 12, 2018 why always true? Link to comment Share on other sites More sharing options...
Share Posted July 12, 2018 5 minutes ago, lucrampro said: why always true? if ($(".scale").mouseover) { ... will always return true because it will return all matching element properties ( i.e not return FALSE ) 1 Link to comment Share on other sites More sharing options...
Share Posted July 12, 2018 looks like there's some action on this one. here is another demo. See the Pen YjXxrz?editors=0010 by GreenSock (@GreenSock) on CodePen 1 Link to comment Share on other sites More sharing options...
Share Posted July 12, 2018 2 minutes ago, lucrampro said: why always true? Because you're just checking if there something called "mouseover" on a jQuery object, which there is. It's called a truthy value. https://developer.mozilla.org/en-US/docs/Glossary/Truthy // Try it console.log(Boolean($(".scale").mouseover)); 4 Link to comment Share on other sites More sharing options...
Author Share Posted July 12, 2018 I understood why I did not succeed thank you for your help! ps: sorry for my bad english because i'm french Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now