When you hover your mouse over a tile in Windows, a cool effect happens:
- Hovering outside the tile, but within the container area:
https://i.sstatic.net/yZk9f.png
- Hovering inside a tile:
https://i.sstatic.net/LoSmk.png
- Hovering outside a tile at its mid point, causing opposite sides to light up:
https://i.sstatic.net/K65cL.png
I'm looking for a way to recreate this effect using CSS and/or JS. Here are some assumptions:
a) Tile positions are fixed
b) Row and column numbers can be accessed with JS
c) All tiles have identical dimensions
d) Container is fully filled with no empty spots
My Approaches:
Initially, I added a mousemove
event listener on the container that looped through all tiles to apply the effect based on mouse position. However, this became slow with more tiles.
Next, I attempted calculations with mouse coordinates relative to the container to identify nearby tiles, but ran into issues, possibly due to incorrect math.
Summary:
Seeking a quicker method to replicate the Windows tile hover effect, even if it's a basic version as long as it looks visually appealing. Any help would be appreciated :)