qqignatqq Posted December 28, 2019 Posted December 28, 2019 Hello. I'm using a small script to change the cursor. Tell me how to make that after refreshing the page, the cursor is set to the previous position. I assumed could use a cookie, but it didn't work out. This line just interrupts my code: gsap.ticker.add(update); https://jsfiddle.net/79pyjgsb/2/
Sahil Posted December 28, 2019 Posted December 28, 2019 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/ 2
qqignatqq Posted December 28, 2019 Author Posted December 28, 2019 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
ZachSaucier Posted December 28, 2019 Posted December 28, 2019 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/ 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now