MG Dev Posted December 10, 2019 Share Posted December 10, 2019 Hi, I'm trying to add animation on hover in my button. The animation work but I'd some issue in the element after the page scroll as you can see in this example How can apply the animation to all page elements? Thank you! See the Pen VwYawbe by MG_Dev (@MG_Dev) on CodePen Link to comment Share on other sites More sharing options...
ZachSaucier Posted December 10, 2019 Share Posted December 10, 2019 Hey MG and welcome to the forums. This isn't really a GSAP question but the answer is straightforward: // This gets the y position and subtracts the amount of scroll so far y: e.clientY - $(window).scrollTop() // It should be this instead y: e.clientY It's best to understand code that you're copying. That way you can catch errors like this and be able to modify it to your needs. Happy tweening. Link to comment Share on other sites More sharing options...
MG Dev Posted December 10, 2019 Author Share Posted December 10, 2019 Thank you fro your reply but unfortunately it doesn't work Maybe the problem is in this line var $self = $(this); // size var width = $self.outerWidth(); var height = $self.outerHeight(); but I can't figure out how to change $self for all page area Link to comment Share on other sites More sharing options...
ZachSaucier Posted December 10, 2019 Share Posted December 10, 2019 Please do not save over previous demos. When you do, context is lost and the old version cannot be referenced to compare to. When creating new versions of the demo, please use the "fork" button on CodePen Changing it to y: e.clientY + $(window).scrollTop() seems to work fine: See the Pen povyyEN?editors=0010 by GreenSock (@GreenSock) on CodePen 1 Link to comment Share on other sites More sharing options...
OSUblake Posted December 10, 2019 Share Posted December 10, 2019 7 hours ago, ZachSaucier said: Changing it to y: e.clientY + $(window).scrollTop() seems to work fine: e.pageY does the same thing. 2 Link to comment Share on other sites More sharing options...
MG Dev Posted December 11, 2019 Author Share Posted December 11, 2019 Yes, this work fine...Thank you! 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