(
arg?:
| string
| (() => unknown)
| {
onComplete?: () => unknown;
next?: string;
loop?: boolean;
speed?: number;
}
// `null` is passed by the internal animation-chain call
// (`setCurrentAnimation(next, null, true)`), so it must be accepted.
| null,
)
| 34 | * @category Animation |
| 35 | */ |
| 36 | export function parseAnimationOptions( |
| 37 | arg?: |
| 38 | | string |
| 39 | | (() => unknown) |
| 40 | | { |
| 41 | onComplete?: () => unknown; |
| 42 | next?: string; |
| 43 | loop?: boolean; |
| 44 | speed?: number; |
| 45 | } |
| 46 | // `null` is passed by the internal animation-chain call |
| 47 | // (`setCurrentAnimation(next, null, true)`), so it must be accepted. |
| 48 | | null, |
| 49 | ): AnimationOptions { |
| 50 | if (typeof arg === "string") { |
| 51 | return { next: arg, loop: true, speed: 1 }; |
| 52 | } |
| 53 | if (typeof arg === "function") { |
| 54 | return { onComplete: arg, loop: true, speed: 1, legacyFn: true }; |
| 55 | } |
| 56 | if (arg !== null && typeof arg === "object") { |
| 57 | return { |
| 58 | onComplete: arg.onComplete, |
| 59 | next: arg.next, |
| 60 | // only an explicit `false` disables looping |
| 61 | loop: arg.loop !== false, |
| 62 | speed: typeof arg.speed === "number" ? arg.speed : 1, |
| 63 | }; |
| 64 | } |
| 65 | return { loop: true, speed: 1 }; |
| 66 | } |
no outgoing calls
no test coverage detected