animot-presenter 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AnimotPresenter.svelte +35 -3
- package/dist/cdn/animot-presenter.esm.js +1413 -1397
- package/dist/cdn/animot-presenter.min.js +8 -8
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -444,6 +444,16 @@
|
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
|
|
447
|
+
// Update elementContent BEFORE animations start so rendered elements
|
|
448
|
+
// (especially SVG viewBox) use target slide data while animating
|
|
449
|
+
for (const elementId of allElementIds) {
|
|
450
|
+
const targetEl = getElementInSlide(targetSlide, elementId);
|
|
451
|
+
if (targetEl && targetEl.type !== 'code') {
|
|
452
|
+
elementContent.set(elementId, JSON.parse(JSON.stringify(targetEl)));
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
elementContent = new Map(elementContent);
|
|
456
|
+
|
|
447
457
|
interface AnimationTask { elementId: string; order: number; delay: number; elementDuration: number; run: () => Promise<void>[]; }
|
|
448
458
|
const animationTasks: AnimationTask[] = [];
|
|
449
459
|
|
|
@@ -552,6 +562,28 @@
|
|
|
552
562
|
if (animated.strokeWidth) anims.push(animated.strokeWidth.to(s.strokeWidth, { duration: elementDuration, easing }));
|
|
553
563
|
}
|
|
554
564
|
if (!currentEl) {
|
|
565
|
+
// Snap ALL properties to target instantly — the tween may hold
|
|
566
|
+
// stale values from a previous slide where the element last appeared
|
|
567
|
+
anims.push(animated.x.to(targetEl.position.x, { duration: 0 }));
|
|
568
|
+
anims.push(animated.y.to(targetEl.position.y, { duration: 0 }));
|
|
569
|
+
anims.push(animated.width.to(targetEl.size.width, { duration: 0 }));
|
|
570
|
+
anims.push(animated.height.to(targetEl.size.height, { duration: 0 }));
|
|
571
|
+
anims.push(animated.rotation.to(targetEl.rotation, { duration: 0 }));
|
|
572
|
+
anims.push(animated.skewX.to(targetEl.skewX ?? 0, { duration: 0 }));
|
|
573
|
+
anims.push(animated.skewY.to(targetEl.skewY ?? 0, { duration: 0 }));
|
|
574
|
+
anims.push(animated.tiltX.to(targetEl.tiltX ?? 0, { duration: 0 }));
|
|
575
|
+
anims.push(animated.tiltY.to(targetEl.tiltY ?? 0, { duration: 0 }));
|
|
576
|
+
anims.push(animated.perspective.to(targetEl.perspective ?? 1000, { duration: 0 }));
|
|
577
|
+
anims.push(animated.borderRadius.to((targetEl as any).borderRadius ?? 0, { duration: 0 }));
|
|
578
|
+
if (targetEl.type === 'text' && animated.fontSize) {
|
|
579
|
+
anims.push(animated.fontSize.to((targetEl as TextElement).fontSize, { duration: 0 }));
|
|
580
|
+
}
|
|
581
|
+
if (targetEl.type === 'shape') {
|
|
582
|
+
const s = targetEl as ShapeElement;
|
|
583
|
+
if (animated.fillColor) anims.push(animated.fillColor.to(s.fillColor, { duration: 0 }));
|
|
584
|
+
if (animated.strokeColor) anims.push(animated.strokeColor.to(s.strokeColor, { duration: 0 }));
|
|
585
|
+
if (animated.strokeWidth) anims.push(animated.strokeWidth.to(s.strokeWidth, { duration: 0 }));
|
|
586
|
+
}
|
|
555
587
|
const entrance = targetEl.animationConfig?.entrance ?? 'fade';
|
|
556
588
|
if (entrance === 'fade') {
|
|
557
589
|
anims.push(animated.opacity.to(1, { duration: elementDuration / 2, easing }));
|
|
@@ -920,11 +952,11 @@
|
|
|
920
952
|
<IconRenderer element={element as IconElement} />
|
|
921
953
|
{:else if element.type === 'svg'}
|
|
922
954
|
{@const svgEl = element as SvgElement}
|
|
923
|
-
{@const
|
|
955
|
+
{@const svgParsed = (() => { const m = svgEl.svgContent.trim().match(/^<svg([^>]*)>([\s\S]*)<\/svg>$/i); if (m) { const vb = m[1].match(/viewBox=["']([^"']+)["']/i); return { inner: m[2], viewBox: vb ? vb[1] : null }; } return { inner: svgEl.svgContent, viewBox: null }; })()}
|
|
924
956
|
<div class="animot-svg-element" style:opacity={svgEl.opacity}>
|
|
925
|
-
<svg width="100%" height="100%" viewBox=
|
|
957
|
+
<svg width="100%" height="100%" viewBox={svgEl.viewBox ?? svgParsed.viewBox ?? `0 0 ${svgEl.size.width} ${svgEl.size.height}`} preserveAspectRatio={svgEl.preserveAspectRatio} xmlns="http://www.w3.org/2000/svg">
|
|
926
958
|
<g style={svgEl.color ? `fill:${svgEl.color};stroke:${svgEl.color}` : ''}>
|
|
927
|
-
{@html
|
|
959
|
+
{@html svgParsed.inner}
|
|
928
960
|
</g>
|
|
929
961
|
</svg>
|
|
930
962
|
</div>
|