| 323 | |
| 324 | // The lens lets go: it settles onto the chosen tab on the light spring. |
| 325 | const settleLens = (index: number) => { |
| 326 | stopLens(); |
| 327 | const pill = pillRef.current; |
| 328 | const track = trackRef.current; |
| 329 | if (!pill || !track) { |
| 330 | return; |
| 331 | } |
| 332 | const width = track.offsetWidth / tabs.length; |
| 333 | pill.style.transition = `transform ${settle.duration}ms ${settle.easing}`; |
| 334 | pill.style.transform = `translateX(${index * width}px)`; |
| 335 | const clear = () => { |
| 336 | pill.style.transition = ''; |
| 337 | pill.style.transform = ''; |
| 338 | pill.removeEventListener('transitionend', clear); |
| 339 | }; |
| 340 | pill.addEventListener('transitionend', clear); |
| 341 | }; |
| 342 | |
| 343 | const onPointerMove = (event: React.PointerEvent<HTMLDivElement>) => { |
| 344 | const { current } = pointer; |