animot-presenter 0.1.2 → 0.2.1
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/README.md +12 -23
- package/dist/AnimotPresenter.svelte +204 -12
- package/dist/cdn/animot-presenter.css +1 -1
- package/dist/cdn/animot-presenter.esm.js +4741 -4511
- package/dist/cdn/animot-presenter.min.js +10 -9
- package/dist/element.svelte.d.ts +33 -4
- package/dist/element.svelte.js +71 -34
- package/dist/engine/utils.d.ts +5 -0
- package/dist/engine/utils.js +18 -0
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +42 -4
- package/package.json +1 -1
package/dist/element.svelte.d.ts
CHANGED
|
@@ -3,20 +3,49 @@ import './styles/presenter.css';
|
|
|
3
3
|
declare class AnimotPresenterElement extends HTMLElement {
|
|
4
4
|
static get observedAttributes(): string[];
|
|
5
5
|
private _component;
|
|
6
|
+
private _pendingRemount;
|
|
7
|
+
private _src;
|
|
6
8
|
private _data;
|
|
9
|
+
private _autoplay;
|
|
10
|
+
private _loop;
|
|
11
|
+
private _controls;
|
|
12
|
+
private _arrows;
|
|
13
|
+
private _progress;
|
|
14
|
+
private _keyboard;
|
|
15
|
+
private _duration;
|
|
16
|
+
private _startSlide;
|
|
7
17
|
private _onslidechange;
|
|
8
18
|
private _oncomplete;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
set data(value: AnimotProject | null);
|
|
19
|
+
get src(): string | null;
|
|
20
|
+
set src(v: string | null);
|
|
12
21
|
get data(): AnimotProject | null;
|
|
22
|
+
set data(v: AnimotProject | null);
|
|
23
|
+
get autoplay(): boolean;
|
|
24
|
+
set autoplay(v: boolean);
|
|
25
|
+
get loop(): boolean;
|
|
26
|
+
set loop(v: boolean);
|
|
27
|
+
get controls(): boolean;
|
|
28
|
+
set controls(v: boolean);
|
|
29
|
+
get arrows(): boolean;
|
|
30
|
+
set arrows(v: boolean);
|
|
31
|
+
get progress(): boolean;
|
|
32
|
+
set progress(v: boolean);
|
|
33
|
+
get keyboard(): boolean;
|
|
34
|
+
set keyboard(v: boolean);
|
|
35
|
+
get duration(): number | undefined;
|
|
36
|
+
set duration(v: number | undefined);
|
|
37
|
+
get startSlide(): number | undefined;
|
|
38
|
+
set startSlide(v: number | undefined);
|
|
39
|
+
get onslidechange(): ((index: number, total: number) => void) | null;
|
|
13
40
|
set onslidechange(fn: ((index: number, total: number) => void) | null);
|
|
41
|
+
get oncomplete(): (() => void) | null;
|
|
14
42
|
set oncomplete(fn: (() => void) | null);
|
|
15
43
|
connectedCallback(): void;
|
|
16
44
|
disconnectedCallback(): void;
|
|
17
45
|
attributeChangedCallback(): void;
|
|
18
46
|
private _buildProps;
|
|
19
|
-
private
|
|
47
|
+
private _cancelPendingRemount;
|
|
48
|
+
private _scheduleRemount;
|
|
20
49
|
private _mount;
|
|
21
50
|
private _unmount;
|
|
22
51
|
next(): void;
|
package/dist/element.svelte.js
CHANGED
|
@@ -6,60 +6,86 @@ import { mount, unmount } from 'svelte';
|
|
|
6
6
|
import AnimotPresenter from './AnimotPresenter.svelte';
|
|
7
7
|
// Inject floating animation CSS into the document (once)
|
|
8
8
|
import './styles/presenter.css';
|
|
9
|
-
const
|
|
9
|
+
const BOOLEAN_PROPS = ['autoplay', 'loop', 'controls', 'arrows', 'progress', 'keyboard'];
|
|
10
10
|
class AnimotPresenterElement extends HTMLElement {
|
|
11
11
|
static get observedAttributes() {
|
|
12
12
|
return ['src', 'autoplay', 'loop', 'controls', 'arrows', 'progress', 'keyboard', 'duration', 'start-slide'];
|
|
13
13
|
}
|
|
14
14
|
_component = null;
|
|
15
|
+
_pendingRemount = null;
|
|
16
|
+
// Property backing stores — React 19 sets these as properties, not attributes
|
|
17
|
+
_src = null;
|
|
15
18
|
_data = null;
|
|
19
|
+
_autoplay = false;
|
|
20
|
+
_loop = false;
|
|
21
|
+
_controls = false;
|
|
22
|
+
_arrows = false;
|
|
23
|
+
_progress = false;
|
|
24
|
+
_keyboard = false;
|
|
25
|
+
_duration = undefined;
|
|
26
|
+
_startSlide = undefined;
|
|
16
27
|
_onslidechange = null;
|
|
17
28
|
_oncomplete = null;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
get
|
|
26
|
-
|
|
27
|
-
}
|
|
29
|
+
// --- Property getters/setters (React 19 sets these directly) ---
|
|
30
|
+
get src() { return this._src ?? this.getAttribute('src'); }
|
|
31
|
+
set src(v) { this._src = v; this._scheduleRemount(); }
|
|
32
|
+
get data() { return this._data; }
|
|
33
|
+
set data(v) { this._data = v; this._scheduleRemount(); }
|
|
34
|
+
get autoplay() { return this._autoplay || this.hasAttribute('autoplay'); }
|
|
35
|
+
set autoplay(v) { this._autoplay = !!v; this._scheduleRemount(); }
|
|
36
|
+
get loop() { return this._loop || this.hasAttribute('loop'); }
|
|
37
|
+
set loop(v) { this._loop = !!v; this._scheduleRemount(); }
|
|
38
|
+
get controls() { return this._controls || this.hasAttribute('controls'); }
|
|
39
|
+
set controls(v) { this._controls = !!v; this._scheduleRemount(); }
|
|
40
|
+
get arrows() { return this._arrows || this.hasAttribute('arrows'); }
|
|
41
|
+
set arrows(v) { this._arrows = !!v; this._scheduleRemount(); }
|
|
42
|
+
get progress() { return this._progress || this.hasAttribute('progress'); }
|
|
43
|
+
set progress(v) { this._progress = !!v; this._scheduleRemount(); }
|
|
44
|
+
get keyboard() { return this._keyboard || this.hasAttribute('keyboard'); }
|
|
45
|
+
set keyboard(v) { this._keyboard = !!v; this._scheduleRemount(); }
|
|
46
|
+
get duration() { return this._duration; }
|
|
47
|
+
set duration(v) { this._duration = v; this._scheduleRemount(); }
|
|
48
|
+
get startSlide() { return this._startSlide; }
|
|
49
|
+
set startSlide(v) { this._startSlide = v; this._scheduleRemount(); }
|
|
50
|
+
get onslidechange() { return this._onslidechange; }
|
|
28
51
|
set onslidechange(fn) {
|
|
29
52
|
this._onslidechange = fn;
|
|
30
|
-
this.
|
|
53
|
+
this._scheduleRemount();
|
|
31
54
|
}
|
|
55
|
+
get oncomplete() { return this._oncomplete; }
|
|
32
56
|
set oncomplete(fn) {
|
|
33
57
|
this._oncomplete = fn;
|
|
34
|
-
this.
|
|
58
|
+
this._scheduleRemount();
|
|
35
59
|
}
|
|
36
60
|
connectedCallback() {
|
|
37
|
-
this._mounted = true;
|
|
38
61
|
this._mount();
|
|
39
62
|
}
|
|
40
63
|
disconnectedCallback() {
|
|
41
|
-
this.
|
|
64
|
+
this._cancelPendingRemount();
|
|
42
65
|
this._unmount();
|
|
43
66
|
}
|
|
44
67
|
attributeChangedCallback() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this._updateProps();
|
|
68
|
+
if (this.isConnected && this._component) {
|
|
69
|
+
this._scheduleRemount();
|
|
48
70
|
}
|
|
49
71
|
}
|
|
50
72
|
_buildProps() {
|
|
51
73
|
const props = {};
|
|
52
|
-
|
|
74
|
+
// Read from property first (React 19), fall back to attribute (vanilla HTML)
|
|
75
|
+
const src = this._src ?? this.getAttribute('src');
|
|
53
76
|
if (src)
|
|
54
77
|
props.src = src;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
78
|
+
props.autoplay = this.autoplay;
|
|
79
|
+
props.loop = this.loop;
|
|
80
|
+
props.controls = this.controls;
|
|
81
|
+
props.arrows = this.arrows;
|
|
82
|
+
props.progress = this.progress;
|
|
83
|
+
props.keyboard = this.keyboard;
|
|
84
|
+
const duration = this._duration ?? this.getAttribute('duration');
|
|
85
|
+
if (duration != null)
|
|
60
86
|
props.duration = Number(duration);
|
|
61
|
-
const startSlide = this.getAttribute('start-slide');
|
|
62
|
-
if (startSlide)
|
|
87
|
+
const startSlide = this._startSlide ?? this.getAttribute('start-slide');
|
|
88
|
+
if (startSlide != null)
|
|
63
89
|
props.startSlide = Number(startSlide);
|
|
64
90
|
if (this._data)
|
|
65
91
|
props.data = this._data;
|
|
@@ -81,30 +107,41 @@ class AnimotPresenterElement extends HTMLElement {
|
|
|
81
107
|
}
|
|
82
108
|
return props;
|
|
83
109
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this._props[key] = newProps[key];
|
|
110
|
+
_cancelPendingRemount() {
|
|
111
|
+
if (this._pendingRemount) {
|
|
112
|
+
clearTimeout(this._pendingRemount);
|
|
113
|
+
this._pendingRemount = null;
|
|
89
114
|
}
|
|
90
115
|
}
|
|
116
|
+
_scheduleRemount() {
|
|
117
|
+
if (!this.isConnected)
|
|
118
|
+
return;
|
|
119
|
+
this._cancelPendingRemount();
|
|
120
|
+
this._pendingRemount = setTimeout(() => {
|
|
121
|
+
this._pendingRemount = null;
|
|
122
|
+
this._unmount();
|
|
123
|
+
this._mount();
|
|
124
|
+
}, 0);
|
|
125
|
+
}
|
|
91
126
|
_mount() {
|
|
92
127
|
if (this._component)
|
|
93
128
|
return;
|
|
94
129
|
if (!this.style.display) {
|
|
95
130
|
this.style.display = 'block';
|
|
96
131
|
}
|
|
97
|
-
|
|
98
|
-
|
|
132
|
+
if (!this.style.height && !this.getAttribute('style')?.includes('height')) {
|
|
133
|
+
this.style.height = '100%';
|
|
134
|
+
}
|
|
99
135
|
this._component = mount(AnimotPresenter, {
|
|
100
136
|
target: this,
|
|
101
|
-
props: this.
|
|
137
|
+
props: this._buildProps()
|
|
102
138
|
});
|
|
103
139
|
}
|
|
104
140
|
_unmount() {
|
|
105
141
|
if (this._component) {
|
|
106
142
|
unmount(this._component);
|
|
107
143
|
this._component = null;
|
|
144
|
+
this.innerHTML = '';
|
|
108
145
|
}
|
|
109
146
|
}
|
|
110
147
|
next() {
|
package/dist/engine/utils.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
export declare function easeLinear(t: number): number;
|
|
2
|
+
export declare function easeInCubic(t: number): number;
|
|
3
|
+
export declare function easeOutCubic(t: number): number;
|
|
1
4
|
export declare function easeInOutCubic(t: number): number;
|
|
5
|
+
export declare function easeSpring(t: number): number;
|
|
6
|
+
export declare function getEasingFn(name?: string): (t: number) => number;
|
|
2
7
|
export declare function interpolateColor(color1: string, color2: string, progress: number): string;
|
|
3
8
|
export declare function hashFraction(str: string, salt?: number): number;
|
|
4
9
|
export declare function getFloatAnimName(direction: string, seed: string): string;
|
package/dist/engine/utils.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
+
export function easeLinear(t) { return t; }
|
|
2
|
+
export function easeInCubic(t) { return t * t * t; }
|
|
3
|
+
export function easeOutCubic(t) { return 1 - Math.pow(1 - t, 3); }
|
|
1
4
|
export function easeInOutCubic(t) {
|
|
2
5
|
return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
|
|
3
6
|
}
|
|
7
|
+
export function easeSpring(t) {
|
|
8
|
+
const c4 = (2 * Math.PI) / 3;
|
|
9
|
+
return t === 0 ? 0 : t === 1 ? 1 : Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * c4) + 1;
|
|
10
|
+
}
|
|
11
|
+
export function getEasingFn(name) {
|
|
12
|
+
switch (name) {
|
|
13
|
+
case 'linear': return easeLinear;
|
|
14
|
+
case 'ease-in': return easeInCubic;
|
|
15
|
+
case 'ease-out': return easeOutCubic;
|
|
16
|
+
case 'spring': return easeSpring;
|
|
17
|
+
case 'ease': return easeOutCubic;
|
|
18
|
+
case 'ease-in-out':
|
|
19
|
+
default: return easeInOutCubic;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
4
22
|
export function interpolateColor(color1, color2, progress) {
|
|
5
23
|
if (color1 === 'transparent')
|
|
6
24
|
color1 = '#00000000';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as AnimotPresenter } from './AnimotPresenter.svelte';
|
|
2
|
-
export type { AnimotProject, AnimotPresenterProps, Slide, SlideCanvas, CanvasElement, CanvasBackground, TransitionConfig, TransitionType, ProjectSettings, BaseElement, CodeElement, TextElement, ArrowElement, ImageElement, ShapeElement, CounterElement, ChartElement, IconElement, ElementAnimationConfig, FloatingAnimationConfig, ParticlesConfig, ConfettiConfig } from './types';
|
|
2
|
+
export type { AnimotProject, AnimotPresenterProps, Slide, SlideCanvas, CanvasElement, CanvasBackground, TransitionConfig, TransitionType, ProjectSettings, BaseElement, CodeElement, TextElement, ArrowElement, ImageElement, ShapeElement, CounterElement, ChartElement, IconElement, SvgElement, MotionPathElement, PathPoint, MotionPathConfig, ElementAnimationConfig, FloatingAnimationConfig, ParticlesConfig, ConfettiConfig } from './types';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ElementType = 'code' | 'text' | 'arrow' | 'image' | 'shape' | 'counter' | 'chart' | 'icon';
|
|
1
|
+
export type ElementType = 'code' | 'text' | 'arrow' | 'image' | 'shape' | 'counter' | 'chart' | 'icon' | 'svg' | 'motionPath';
|
|
2
2
|
export type ShapeType = 'rectangle' | 'circle' | 'triangle' | 'ellipse' | 'star' | 'hexagon';
|
|
3
3
|
export interface Position {
|
|
4
4
|
x: number;
|
|
@@ -9,19 +9,23 @@ export interface Size {
|
|
|
9
9
|
height: number;
|
|
10
10
|
}
|
|
11
11
|
export type TiltOrigin = string;
|
|
12
|
-
export type AnimatableProperty = 'position' | 'rotation' | 'tilt' | 'skew' | 'size' | 'opacity' | 'borderRadius' | 'color';
|
|
12
|
+
export type AnimatableProperty = 'position' | 'rotation' | 'tilt' | 'skew' | 'size' | 'opacity' | 'borderRadius' | 'color' | 'perspective';
|
|
13
13
|
export interface PropertySequence {
|
|
14
14
|
property: AnimatableProperty;
|
|
15
15
|
order: number;
|
|
16
16
|
delay: number;
|
|
17
17
|
duration: number;
|
|
18
18
|
}
|
|
19
|
+
export type EntranceAnimation = 'fade' | 'none';
|
|
20
|
+
export type ExitAnimation = 'fade' | 'none';
|
|
19
21
|
export interface ElementAnimationConfig {
|
|
20
22
|
order: number;
|
|
21
23
|
delay: number;
|
|
22
24
|
duration: number;
|
|
23
25
|
easing: 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
|
|
24
26
|
propertySequences?: PropertySequence[];
|
|
27
|
+
entrance?: EntranceAnimation;
|
|
28
|
+
exit?: ExitAnimation;
|
|
25
29
|
}
|
|
26
30
|
export type FloatingDirection = 'vertical' | 'horizontal' | 'both';
|
|
27
31
|
export interface FloatingAnimationConfig {
|
|
@@ -32,6 +36,20 @@ export interface FloatingAnimationConfig {
|
|
|
32
36
|
amplitudeRandomness: number;
|
|
33
37
|
speedRandomness: number;
|
|
34
38
|
}
|
|
39
|
+
export interface PathPoint {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
handleIn?: Position;
|
|
43
|
+
handleOut?: Position;
|
|
44
|
+
}
|
|
45
|
+
export interface MotionPathConfig {
|
|
46
|
+
motionPathId: string;
|
|
47
|
+
startPercent: number;
|
|
48
|
+
endPercent: number;
|
|
49
|
+
autoRotate: boolean;
|
|
50
|
+
orientationOffset: number;
|
|
51
|
+
loop: boolean;
|
|
52
|
+
}
|
|
35
53
|
export interface BaseElement {
|
|
36
54
|
id: string;
|
|
37
55
|
type: ElementType;
|
|
@@ -48,8 +66,12 @@ export interface BaseElement {
|
|
|
48
66
|
tiltOrigin: TiltOrigin;
|
|
49
67
|
zIndex: number;
|
|
50
68
|
visible: boolean;
|
|
69
|
+
perspective?: number;
|
|
70
|
+
backfaceVisibility?: 'visible' | 'hidden';
|
|
51
71
|
animationConfig?: ElementAnimationConfig;
|
|
52
72
|
floatingAnimation?: FloatingAnimationConfig;
|
|
73
|
+
motionPathId?: string;
|
|
74
|
+
motionPathConfig?: MotionPathConfig;
|
|
53
75
|
}
|
|
54
76
|
export type CodeAnimationMode = 'instant' | 'typewriter' | 'highlight-changes';
|
|
55
77
|
export interface CodeAnimationConfig {
|
|
@@ -139,6 +161,7 @@ export interface ImageElement extends BaseElement {
|
|
|
139
161
|
borderRadius: number;
|
|
140
162
|
opacity: number;
|
|
141
163
|
blur: number;
|
|
164
|
+
backgroundColor?: string;
|
|
142
165
|
clipMask?: {
|
|
143
166
|
enabled: boolean;
|
|
144
167
|
shapeType: ShapeType;
|
|
@@ -214,7 +237,22 @@ export interface IconElement extends BaseElement {
|
|
|
214
237
|
strokeWidth: number;
|
|
215
238
|
fillMode: 'stroke' | 'fill' | 'both';
|
|
216
239
|
}
|
|
217
|
-
export
|
|
240
|
+
export interface SvgElement extends BaseElement {
|
|
241
|
+
type: 'svg';
|
|
242
|
+
svgContent: string;
|
|
243
|
+
color?: string;
|
|
244
|
+
opacity: number;
|
|
245
|
+
preserveAspectRatio: string;
|
|
246
|
+
}
|
|
247
|
+
export interface MotionPathElement extends BaseElement {
|
|
248
|
+
type: 'motionPath';
|
|
249
|
+
points: PathPoint[];
|
|
250
|
+
closed: boolean;
|
|
251
|
+
pathColor: string;
|
|
252
|
+
pathWidth: number;
|
|
253
|
+
showInPresentation: boolean;
|
|
254
|
+
}
|
|
255
|
+
export type CanvasElement = CodeElement | TextElement | ArrowElement | ImageElement | ShapeElement | CounterElement | ChartElement | IconElement | SvgElement | MotionPathElement;
|
|
218
256
|
export type ParticleShape = 'circle' | 'square' | 'star' | 'triangle';
|
|
219
257
|
export interface ParticlesConfig {
|
|
220
258
|
enabled: boolean;
|
|
@@ -252,7 +290,7 @@ export interface CanvasBackground {
|
|
|
252
290
|
particles?: ParticlesConfig;
|
|
253
291
|
confetti?: ConfettiConfig;
|
|
254
292
|
}
|
|
255
|
-
export type TransitionType = 'none' | 'fade' | 'slide-left' | 'slide-right' | 'slide-up' | 'slide-down' | 'zoom-in' | 'zoom-out' | 'flip';
|
|
293
|
+
export type TransitionType = 'none' | 'fade' | 'slide-left' | 'slide-right' | 'slide-up' | 'slide-down' | 'zoom-in' | 'zoom-out' | 'flip' | 'flip-x' | 'flip-y';
|
|
256
294
|
export interface TransitionConfig {
|
|
257
295
|
type: TransitionType;
|
|
258
296
|
duration: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "animot-presenter",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Embed animated presentations anywhere. Works with vanilla JS, React, Vue, Angular, Svelte, and any frontend framework. Morphing animations, code highlighting, charts, particles, and more.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"svelte": "./dist/index.js",
|