Jump to content
Search Community

Animating button on hover

MG Dev test
Moderator Tag

Recommended Posts

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

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

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

 

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