0

Event listeners (mousemove)

I have a some code that is giving me trouble. Here it is https://code.sololearn.com/WL1qmBlorEd0/#html I want the circle to follow my mouse positioning. I have tried to trouble-shooting it and it look like the mouse.x and the mouse.y are not changing to the client X and Y. I have spent two whole days trying to figure this one out. If you could give me any tips to help problem that would be wonderful. Any help would greatly be appreciated. Thank you

23rd May 2018, 8:00 AM
Bradley
4 odpowiedzi
+ 5
This would better if you put in the code,nobody can run your post
23rd May 2018, 8:10 AM
᠌᠌Code X
᠌᠌Code X - avatar
+ 3
You need to draw the circle each time the event handler function is called, and clear the canvas before (so redraw the "background circle" too if you want preserve it) if you want to give illusion of movement (else you just draw a new circle at each new mouse position)... However, the "mousemove" event is not (well) handled on touch devices, so if you want to get it working with all devices, I suggest you to define also an event listener for the "touchmove" event: https://code.sololearn.com/Wzag91JQXstA/?ref=app#html
23rd May 2018, 3:26 PM
visph
visph - avatar
+ 2
Exactly Bradley
23rd May 2018, 11:00 AM
᠌᠌Code X
᠌᠌Code X - avatar
0
What do you mean by "put in the code"? Do you mean put it in the code playground and then send a link?
23rd May 2018, 10:45 AM
Bradley