|
@@ -51,10 +51,11 @@ export function useSvgAnimation(elementInfo: Map<string, { key: string; transfor
|
|
|
const animateElement = (elementId: string, toEnd: boolean, duration = 3000, progress = 1) => {
|
|
|
const el = animationElements.get(elementId);
|
|
|
const info = elementInfo.get(elementId);
|
|
|
+ progress = _.clamp(progress, 0, 1);
|
|
|
|
|
|
if (el && info && info.transforms.length > 1) {
|
|
|
- const endTransform = _.nth(info.transforms, Math.floor(info.transforms.length * progress));
|
|
|
- const startTransform = _.nth(info.transforms, -Math.ceil(info.transforms.length * progress));
|
|
|
+ const endTransform = info.transforms[Math.floor((info.transforms.length - 1) * progress)];
|
|
|
+ const startTransform = info.transforms[Math.floor((info.transforms.length - 1) * (1 - progress))];
|
|
|
el.style.transition = `transform ${duration}ms`;
|
|
|
el.setAttribute('transform', toEnd ? endTransform : startTransform);
|
|
|
}
|