Jump to content
Search Community

Follow cursor created with quickSetter() does not work

bs.choi test
Moderator Tag

Recommended Posts

Hi.
I made a follow cursor using gsap's quickSetter and ticker.

Originally there was no problem, but a bug occurred while refactoring.

I really don't know why.

 

new ver

https://jsfiddle.net/kebqswL4/6/

 

previous ver

https://jsfiddle.net/kebqswL4/7/

 

The reason I did the refactoring was because I wanted to handle similar calculations in one function.

Please help me...

Link to comment
Share on other sites

We really try to keep these forums focused on GSAP-specific questions (not general logic ones), but I assume this is what you wanted: 

https://jsfiddle.net/cxLesp36/

 

Your code was assuming that this was actually changing the pos.y/pos.x: 

const posSet = (p, m, d) => p += (m - p) * d;

But it wasn't - that is merely changing the LOCAL VARIABLE named "p". 

 

You also had typos where you used "y" instead of "x":

// bad
const xSetFollowPos = posSet(posF.y, mouse.y, dtF);

// good
const xSetFollowPos = posSet(posF.x, mouse.x, dtF);

Good luck!

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