26 lines
773 B
JavaScript
26 lines
773 B
JavaScript
export function findStepModuleAnimation(definition, animationId) {
|
|
const animations = Array.isArray(definition?.animations) ? definition.animations : [];
|
|
if (!animations.length) {
|
|
return null;
|
|
}
|
|
const normalizedId = String(animationId || "").trim();
|
|
return animations.find((animation) => animation.id === normalizedId) || animations[0] || null;
|
|
}
|
|
|
|
export function buildDefaultStepModuleAnimationState(definition) {
|
|
const animation = findStepModuleAnimation(definition, "");
|
|
return {
|
|
activeId: animation?.id || "",
|
|
playing: false,
|
|
elapsedSec: 0,
|
|
speed: 1
|
|
};
|
|
}
|
|
|
|
export function animationNowMs() {
|
|
if (typeof performance !== "undefined" && typeof performance.now === "function") {
|
|
return performance.now();
|
|
}
|
|
return Date.now();
|
|
}
|