My understanding is that all the script-y stuff is already in the background. All that’s needed is to import the library, declare it in HTML, then style away in CSS.
Like, here’s Chris a long while back with custom properties registered in JavaScript to track cursor position:
CodePen Embed Fallback
Prop For That has that nicely covered. The difference is that we’re working with data attributes that trigger the scripts:
<div class="mover" data-props-for="pointer">...</div>And plop the relevant props into the styles:.mover {
aspect-ratio: 1;
width: 50px;
background: red;
position: absolute;
left: calc(var(--live-pointer-x, 0) * 1px);
top: calc(var(--live-pointer-y, 0) * 1px);
}CodePen Embed FallbackThe demos are where it’s at. Good lord, can Adam put together some classy work.
Prop For That originally handwritten and published with love on CSS-Tricks. You should really get the newsletter as well.
https://css-tricks.com/prop-for-that/
