(anim: GsapAnimation)
| 180 | } |
| 181 | |
| 182 | function surfaceTween(anim: GsapAnimation): SurfacedTween { |
| 183 | const start = |
| 184 | typeof anim.resolvedStart === "number" ? anim.resolvedStart : (num(anim.position) ?? 0); |
| 185 | const duration = anim.duration ?? 0; |
| 186 | |
| 187 | let shape: SurfacedTween["shape"]; |
| 188 | let rawKfs: Array<{ percentage: number; properties: Record<string, number | string> }>; |
| 189 | if (anim.keyframes?.keyframes?.length) { |
| 190 | shape = "keyframes"; |
| 191 | rawKfs = anim.keyframes.keyframes; |
| 192 | } else if (anim.arcPath?.enabled) { |
| 193 | shape = "motionPath"; |
| 194 | rawKfs = []; |
| 195 | } else { |
| 196 | shape = "flat"; |
| 197 | rawKfs = flatKeyframes(anim).map((k) => ({ percentage: k.pct, properties: k.properties })); |
| 198 | } |
| 199 | |
| 200 | const keyframes: KeyframePoint[] = rawKfs.map((kf) => ({ |
| 201 | pct: kf.percentage, |
| 202 | time: Math.round((start + (kf.percentage / 100) * duration) * 1000) / 1000, |
| 203 | properties: cleanProps(kf.properties), |
| 204 | })); |
| 205 | |
| 206 | return { |
| 207 | id: anim.id, |
| 208 | target: anim.targetSelector, |
| 209 | method: anim.method, |
| 210 | group: anim.propertyGroup, |
| 211 | start: Math.round(start * 1000) / 1000, |
| 212 | duration, |
| 213 | end: Math.round((start + duration) * 1000) / 1000, |
| 214 | shape, |
| 215 | keyframes, |
| 216 | path: isPositionTween(anim) ? positionPath(keyframes) : null, |
| 217 | }; |
| 218 | } |
| 219 | |
| 220 | // Carry x/y forward across keyframes that only set one axis, so the path is |
| 221 | // continuous (GSAP holds the last value for an unspecified property). |
nothing calls this directly
no test coverage detected