| 303 | }; |
| 304 | |
| 305 | const moveLens = (target: number) => { |
| 306 | if (!lens.current) { |
| 307 | const pill = pillRef.current; |
| 308 | const start = |
| 309 | pill && typeof DOMMatrixReadOnly !== 'undefined' |
| 310 | ? new DOMMatrixReadOnly(getComputedStyle(pill).transform).e |
| 311 | : target; |
| 312 | lens.current = { |
| 313 | target, |
| 314 | pos: start, |
| 315 | vel: 0, |
| 316 | frame: 0, |
| 317 | last: performance.now(), |
| 318 | }; |
| 319 | lens.current.frame = requestAnimationFrame(stepLens); |
| 320 | } |
| 321 | lens.current.target = target; |
| 322 | }; |
| 323 | |
| 324 | // The lens lets go: it settles onto the chosen tab on the light spring. |
| 325 | const settleLens = (index: number) => { |