Jump to content
Search Community

Restore cursor position

qqignatqq test
Moderator Tag

Recommended Posts

You can use cookies and trigger the mousemove event by creating jQuery's event.

 

https://jsfiddle.net/ds6t5zec/1/

 

Instead of triggering event you can just set the cursors position on load so it won't animate from (0, 0).  A better way would to just animate cursor in on first event, like scale it up where mouse is. That way you won't have to worry about cookies and it also takes care of how cursor animates when user visits for the first time. I had to use quickSetter method to avoid overwriting transform as it will interrupt scaling animation.

 

https://jsfiddle.net/gpnta9oL/13/

 

 

  • Like 2
Link to comment
Share on other sites

1 hour ago, Sahil said:

You can use cookies and trigger the mousemove event by creating jQuery's event.

 

https://jsfiddle.net/gpnta9oL/5/

 

Instead of triggering event you can just set the cursors position on load so it won't animate from (0, 0).  A better way would to just animate cursor in on first event, like scale it up where mouse is. That way you won't have to worry about cookies and it also takes care of how cursor animates when user visits for the first time. I had to use quickSetter method to avoid overwriting transform as it will interrupt scaling animation.

 

https://jsfiddle.net/gpnta9oL/12/

 

 

Bug. It's not always the cursor that appears. 

https://yadi.sk/i/ej_YxD89eVx-xg

Link to comment
Share on other sites

40 minutes ago, qqignatqq said:

Bug. It's not always the cursor that appears. 

https://yadi.sk/i/ej_YxD89eVx-xg

That's because Sahil placed the logic in a mouseenter instead of the mousemove listener. So if your cursor is over the page when the page loads the mouseenter will not fire until it leaves the page and then goes back to it. You can fix it by moving it to within the mousemove listener and adding an else for the "regular" mousemove functionality: https://jsfiddle.net/06zd9cbf/

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