(now: number)
| 279 | // One spring step per frame: position chases the finger, the squash |
| 280 | // follows the speed, and the lens stays lifted while held. |
| 281 | const stepLens = (now: number) => { |
| 282 | const state = lens.current; |
| 283 | const pill = pillRef.current; |
| 284 | if (!state || !pill) { |
| 285 | return; |
| 286 | } |
| 287 | const dt = Math.min(32, now - state.last) / 1000; |
| 288 | state.last = now; |
| 289 | const { stiffness, damping } = cluster.spring; |
| 290 | const acceleration = |
| 291 | (state.target - state.pos) * stiffness - state.vel * damping; |
| 292 | state.vel += acceleration * dt; |
| 293 | state.pos += state.vel * dt; |
| 294 | const squash = Math.min( |
| 295 | Math.abs(state.vel) * (cluster.squashPerPxPerMs / 1000), |
| 296 | cluster.squashMax, |
| 297 | ); |
| 298 | pill.style.transition = 'none'; |
| 299 | pill.style.transform = `translateX(${state.pos}px) scale(${ |
| 300 | cluster.lensScale |
| 301 | }) scaleX(${1 + squash}) scaleY(${1 / (1 + squash)})`; |
| 302 | state.frame = requestAnimationFrame(stepLens); |
| 303 | }; |
| 304 | |
| 305 | const moveLens = (target: number) => { |
| 306 | if (!lens.current) { |
nothing calls this directly
no outgoing calls
no test coverage detected