Jump to content
Search Community

Mouse glitch on scrollEffect

makilyes test
Moderator Tag

Recommended Posts

Hello,

I'm a beginner developper and just started with Gsap and I'm doing a project on React

I wanted to have a dot cursor, and onScroll it changes shape or color. For this point it's ok, perhaps each time I change section, the scroll gets triggered, and I have the shape that glitches (goes to the left, or 'x' position, to get back at the cursor position). It happens each time it gets called.

 

I did a codePen just with one section, when we scroll down slowly, at some point you can see the shape moving to the left, to then get back following the cursor.

 

Thank you for your help, and sorry for my bad english ;)

 

 

1.png

2.png

See the Pen YzrxzZX by shahyne (@shahyne) on CodePen

Link to comment
Share on other sites

Welcome to the forums @makilyes

 

You are overwriting your inline styles every time one of your ScrollTrigger callbacks is called, which gets rid of the transforms.

 

You can just set what you want, like this.

gsap.set(".app-cursor", {
  "--box-shadow": "0 4px 48px 24px #ffcd03"
})

 

But it might simpler to just add and remove CSS classes with those settings. 

 

And as for setting the transforms, it's better to let GSAP handle that. You can use a quickerSetter for that. 

 

See the Pen WNNNBpo 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...