JavaScript30 day 22: Follow along links

The goal for this challenge was to create a hover state that follows the cursor. The end result is a highlight that jumps from link to link: demo.

There’s some interesting things going on to get the dimensions of the element and to work out the cursor position on screen.

Today’s useful method that I’d never heard of is Element.getBoundingClientRect() which returns the size of an element and its position relative to the viewport.

The files for this project are on github.