Jump to content
Search Community

[Framer Motion] Mouse follower - onScroll [issue]

ilyasseisov

Recommended Posts

Posted

Hi!

 

Could you please help?
I have a mouse follower effect, it works, but I need it to stick to the cursor when scroll happens.
I've tried many things, but no success.

Example of the website where it works as I need:
https://minhpham.design/

 

Here is my StackBlitz:
https://stackblitz.com/edit/vite-react-tailwind-qeksd3?file=src%2FApp.jsx

 

If you are able to solve this issue, please let know how much money do you want for the solution.

 

Thanks in advance!

 

p.s. [for forum moderators]: I hope I'm not violating the forum rules. If am please let me know and I will remove the topic.

Posted

Hi,

 

Yeah why this happens is quite simple actually. The mouse follow tween is triggered by the mousemove event. If you don't move the mouse pointer while scrolling the follower will obviously not follow the pointer, pretty simple. Solving this is a far different challenge and not a simple one I'm afraid. You have to record the last position of the pointer (you can basically store that on every mouse moveevent handler) and as you. scroll up/down move the follower accordingly based on the amount of pixels scrolled.

 

That is the first thing that comes to my mind as to how this can be tackled, but again, this might not be the simplest thing to achieve and unfortunately we don't have the time resources to provide a complex demo like this, is beyond the scope of what we do on these free forums

 

Hopefully this gets you on the right direction

Happy Tweening!

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