Jump to content
GreenSock

Ivan Mocs

position does not match the cursor position when the page is scrolled

Moderator Tag
Go to solution Solved by GreenSock,

Recommended Posts

position does not match the cursor position when the page is scrolled. the position of the image is even away from the cursor and not in the center of the cursor

See the Pen poZPVgV by adeivan (@adeivan) on CodePen

Link to comment
Share on other sites

  • Solution

That's because you're using event.x/y instead of event.pageX/pageY. 

 

Also, I'm not sure why you're animating EVERY image on every mousemove event.  Wouldn't it be more efficient to just animate the container? I'd recommend using gsap.quickTo() for the mousemove stuff too in order to maximize performance rather than creating a whole new tween on every event:

 

See the Pen ExpmLXB by GreenSock (@GreenSock) on CodePen

 

Better? 

  • Like 1
  • Thanks 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.
×