FIG-001/ USETRANSFORM

pointer-tracking gradient.

Move the cursor across the swatch. Two writable stores track the pointer position; useTransform derives the conic-gradient(...) background string from them; styleString paints it onto the inline style.

  • Two writable stores (gradientX, gradientY) hold the pointer's normalised position. onpointermove writes to them; the derived background re-evaluates synchronously.
  • useTransform(fn, deps) returns a derived motion value that recomputes whenever any dep store changes. The fn produces the full conic-gradient(...) string by interpolating store values into a template literal.
  • styleString serialises the derived value object onto the inline style attribute. Re-evaluates every time $background emits, keeping the gradient in lockstep with the pointer.
↩ all examples
pattern · derived-style mode · live running source
category · usetransform
sheet · sheet 01 / 01
⟳ to re-run