Mouse move over element, parallax mouse hover effect

Hi everyone,

I’m currently attempting to create a gallery view with a parallax mouse hover effect, where elements respond to mouse movement.

In this video, the pink background represents my canvas and the green boxes are the items.
I’ve set up my section to be 100vw/100vh and adjusted the position of the green box using relative positioning.

Sadly, whenever I move the cursor out of the pink section to click a green box (out side of section), it starts shaking continuously.

My goal is to design a page that is horizontally super long, enabling users to select items by moving the cursor.

Can anybody help me out ?

Thanks a lot

Screen Recording 2023-10-15 at 3.12.50 PM-2