(timestamp: number)
| 143 | } |
| 144 | |
| 145 | const animate = (timestamp: number) => { |
| 146 | if (lastTimestampRef.current === null) { |
| 147 | lastTimestampRef.current = timestamp; |
| 148 | } |
| 149 | |
| 150 | const deltaTime = Math.max(0, timestamp - lastTimestampRef.current) / 1000; |
| 151 | lastTimestampRef.current = timestamp; |
| 152 | |
| 153 | const target = isHovered && hoverSpeed !== undefined ? hoverSpeed : targetVelocity; |
| 154 | |
| 155 | const easingFactor = 1 - Math.exp(-deltaTime / ANIMATION_CONFIG.SMOOTH_TAU); |
| 156 | velocityRef.current += (target - velocityRef.current) * easingFactor; |
| 157 | |
| 158 | if (seqSize > 0) { |
| 159 | let nextOffset = offsetRef.current + velocityRef.current * deltaTime; |
| 160 | nextOffset = ((nextOffset % seqSize) + seqSize) % seqSize; |
| 161 | offsetRef.current = nextOffset; |
| 162 | |
| 163 | const transformValue = isVertical |
| 164 | ? `translate3d(0, ${-offsetRef.current}px, 0)` |
| 165 | : `translate3d(${-offsetRef.current}px, 0, 0)`; |
| 166 | track.style.transform = transformValue; |
| 167 | } |
| 168 | |
| 169 | rafRef.current = requestAnimationFrame(animate); |
| 170 | }; |
| 171 | |
| 172 | rafRef.current = requestAnimationFrame(animate); |
| 173 |
no outgoing calls
no test coverage detected