Jump to content
Search Community

ScrollTrigger messing with clientX/clientY and pageX/pageY

duppz test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi, I'm new here and have searched a lot for a solution and found no answer.

I got this marquee type lines that change x position with ScrollTrigger, and also an effect when hovering the links with the following image, based on this solution already posted here (

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

).

The problem is that if I turn off the ScrollTrigger, everything is fine, but when I turn it on, the clientX and clientY get messy. Even if I turn off the randon x position before the trigger, the Y position still isn't correct.

I even put the quickSetter example of the blue ball with pageX and pageY and it also is not right.

The idea is that the image follows the links even if the page is scrolled, which makes the x and y positions even more random.

Your help is very appreciated. 

Thanks!

See the Pen abRpeXb by duppz (@duppz) on CodePen

Link to comment
Share on other sites

  • Solution

That's a CSS issue - you've got a position: fixed element inside a container that has a transform applied.  Whenever you have a transform applied to an element, it creates a new stacking context, making an descendent position: fixed elements position themselves relative to that container with the transform.

 

You'll need to either change your markup so that the mouse follower elements are outside of that container or adjust your x/y to accommodate the container's position.  

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