Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
MG Dev

Animating button on hover

Recommended Posts

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 post
Share on other sites

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 post
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 post
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 post
Share on other sites
7 hours ago, ZachSaucier said:

Changing it to y: e.clientY + $(window).scrollTop() seems to work fine:

 

e.pageY does the same thing.

  • Like 2
Link to post
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.

×