| 102 | } |
| 103 | |
| 104 | const animate = timestamp => { |
| 105 | if (lastTimestampRef.current === null) { |
| 106 | lastTimestampRef.current = timestamp; |
| 107 | } |
| 108 | |
| 109 | const deltaTime = Math.max(0, timestamp - lastTimestampRef.current) / 1000; |
| 110 | lastTimestampRef.current = timestamp; |
| 111 | |
| 112 | const target = isHovered && hoverSpeed !== undefined ? hoverSpeed : targetVelocity; |
| 113 | |
| 114 | const easingFactor = 1 - Math.exp(-deltaTime / ANIMATION_CONFIG.SMOOTH_TAU); |
| 115 | velocityRef.current += (target - velocityRef.current) * easingFactor; |
| 116 | |
| 117 | if (seqSize > 0) { |
| 118 | let nextOffset = offsetRef.current + velocityRef.current * deltaTime; |
| 119 | nextOffset = ((nextOffset % seqSize) + seqSize) % seqSize; |
| 120 | offsetRef.current = nextOffset; |
| 121 | |
| 122 | const transformValue = isVertical |
| 123 | ? `translate3d(0, ${-offsetRef.current}px, 0)` |
| 124 | : `translate3d(${-offsetRef.current}px, 0, 0)`; |
| 125 | track.style.transform = transformValue; |
| 126 | } |
| 127 | |
| 128 | rafRef.current = requestAnimationFrame(animate); |
| 129 | }; |
| 130 | |
| 131 | rafRef.current = requestAnimationFrame(animate); |
| 132 |
no outgoing calls
no test coverage detected