Documentation

Documentation

JavaScript

springValue

springValue

Checking Motion+ status…

Unlocks for everyone in

29 Days 15 Hours 13 Minutes

Or

One-time payment, no subscription

Already joined?

Checking Motion+ status…

Unlocks for everyone in

29 Days 15 Hours 13 Minutes

Or

One-time payment, no subscription

Already joined?

Checking Motion+ status…

Unlocks for everyone in

29 Days 15 Hours 13 Minutes

Or

One-time payment, no subscription

Already joined?

springValue creates a new motion value that reacts to changes with a physics-based spring animation.

springValue either accepts a number:

const x = springValue(0)
const y = springValue("100%")

// These will go to their new target with a spring animation
x.set(100)
y.set("0%")

styleEffect("div", { x, y })

Or another motion value:

const pointerX = motionValue(0)
const x = springValue(pointerX)

document.addEventListener("pointerMove", (e) => {
  // x will animate these changes with a spring animation
  pointerX.set(e.clientX)
})

styleEffect("div", { x })
Stay in the loop

Subscribe for the latest news & updates.

Stay in the loop

Subscribe for the latest news & updates.