Table of Contents
Introduction
Observations
Getting Started
The Crux
Finding nearby elements to cursor
How to Calculate nearby point...
For further actions, you may consider blocking this person and/or reporting abuse
interesting article, thanks, and just few quick notes:
nearBy.splice(0, nearBy.length)
could just be
nearBy.splice(0)
element.className
could rather be
element.classList.contains('win-btn')
last, but not least, it's not clear why some event is directly attached, and some is added via proper method ... anyway, thanks for the write up and the code 👋
Thanks, @webreflection for the splice suggestion. I will use that 😁.
I have almost completed the 3rd article of this series and I have already used the classList property there since I wanted to show both the approaches to the readers.
Coming to your query about direct event vs methods, the DOM element does not have a property called
onmousemove
. That's why I had to useaddEventListener
method for that particular event.For reference, I have done
console.dir()
of a DOM element to check the sameI Hope this helps 😉
'onmousemove' in HTMLElement.prototype
intrue
, and every event should be added viaaddEventListener
to avoid conflicts with other possible events.b.onmouseleave
should beb.addEventListener('mouseleave', ...)
and the other too, or you can usehandleEvent
with an object right away.As summary, this is how I would've written that:
Nice ✨
if you look closer, you also have one object as listener, with 4 methods, instead of N x 3 functions per each
.win-btn
on the page ... it's both a RAM and a CPU win ;-)Do you always prefer this syntax over normal syntax? Since you have a ton of experience in JS, I would like to know what more improvisations can be made 😬. Please give your feedback on part 3 also
not sure this answers your question: webreflection.medium.com/dom-handl... 👋
Great explanation!
Thankyou professor 🤓
Waah Gopani Ji Waah! XD
Thanks for explaining every aspect of the code, including why you didn't use map() or forEach(). Great post!
Thankyou Gandhi Ji 🙌
Great logic and explanation ..never thought that such a simple ui would be that difficult to make.
Less is more 😂
Hi,
first of all thank you so much for making the code for this effect and the detailed explanation of the code.
I want to apply the same effect in my project but have to do some modifications, one of which is that i want to add an image also with the text in each grid item but after doing that the affect is not working properly.
The problem is that if i hover over any grid item that contains the image, there are some points at which the hover effect doesnt work.
I dont know what is the problem or what to change in code to make it work properly.
Please help!!!
Problem 1:
Problem 2:
wonderful jash 👍
Thankyou😇
A great descriptive article. Very well written and the memes in the middle provided a good laugh and made me enjoy the article a bit more.
Thanks a lot🤟