Is there a way to make something (ex: an image ) follow the cursor? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Is there a way to make something (ex: an image ) follow the cursor?

No description.

7th May 2019, 6:34 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
11 Answers
+ 5
Mouseover event
7th May 2019, 6:50 AM
Calviղ
Calviղ - avatar
+ 6
⚡Prometheus ⚡ event can detect mouse location
7th May 2019, 7:20 AM
Calviղ
Calviղ - avatar
+ 5
I never used that even , and I don't really know how it works.😅
7th May 2019, 7:53 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
7th May 2019, 8:24 AM
Calviղ
Calviղ - avatar
+ 5
Calviղ Also mention that for mobile users just simply touch the screen at that place.
7th May 2019, 8:38 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
Calviղ How does the mouseover event do it? Is there any sort of property binding equivalent in JavaScript? (Inspired by JavaFX btw)
7th May 2019, 6:52 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
What is " evt.clientX-32"?
7th May 2019, 8:44 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 4
Calviղ so , the image is 64px width , and to align it at the center of the cursor , you made half of it.(32px).
7th May 2019, 8:56 AM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 2
🌲 Alex Tusinean 🔥 you're right 😊
7th May 2019, 8:57 AM
Calviղ
Calviղ - avatar
+ 1
🌲 Alex Tusinean 🔥Current mouse position x - 32px (half length of img)
7th May 2019, 8:50 AM
Calviղ
Calviղ - avatar
+ 1
⚡Prometheus ⚡ you can add touchmove event for mobile touch.
7th May 2019, 8:52 AM
Calviղ
Calviղ - avatar