@aarsteinmedia/dotlottie-player 6.0.4 → 6.0.5

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/full.d.ts CHANGED
@@ -4,6 +4,8 @@ import * as _aarsteinmedia_lottie_web from '@aarsteinmedia/lottie-web';
4
4
  import { Vector2, AnimationConfiguration, AnimationData, AnimationDirection, AddAnimationParams, Result, ConvertParams, AnimationItem, LottieManifest, AnimationSettings } from '@aarsteinmedia/lottie-web';
5
5
  import { addAnimation, convert } from '@aarsteinmedia/lottie-web/dotlottie';
6
6
  import * as _aarsteinmedia_lottie_web_light from '@aarsteinmedia/lottie-web/light';
7
+ import * as _aarsteinmedia_lottie_web_canvas from '@aarsteinmedia/lottie-web/canvas';
8
+ import * as _aarsteinmedia_lottie_web_svg from '@aarsteinmedia/lottie-web/svg';
7
9
 
8
10
  declare class DotLottiePlayerLight extends DotLottiePlayerBase {
9
11
  loadAnimation: typeof _aarsteinmedia_lottie_web_light.loadAnimation;
@@ -31,6 +33,34 @@ declare enum PlayerState {
31
33
  }
32
34
  declare const tagName = "dotlottie-player";
33
35
 
36
+ declare class DotLottiePlayerCanvas extends DotLottiePlayerBase {
37
+ loadAnimation: typeof _aarsteinmedia_lottie_web_canvas.loadAnimation;
38
+ get renderer(): RendererType;
39
+ constructor();
40
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
41
+ container?: HTMLElement;
42
+ rendererType: RendererType;
43
+ initialSegment?: Vector2;
44
+ hasAutoplay: boolean;
45
+ hasLoop: boolean;
46
+ preserveAspectRatio: PreserveAspectRatio;
47
+ }): AnimationConfiguration<RendererType.Canvas>;
48
+ }
49
+
50
+ declare class DotLottiePlayerSVG extends DotLottiePlayerBase {
51
+ loadAnimation: typeof _aarsteinmedia_lottie_web_svg.loadAnimation;
52
+ get renderer(): RendererType;
53
+ constructor();
54
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
55
+ container?: HTMLElement;
56
+ rendererType: RendererType;
57
+ initialSegment?: Vector2;
58
+ hasAutoplay: boolean;
59
+ hasLoop: boolean;
60
+ preserveAspectRatio: PreserveAspectRatio;
61
+ }): AnimationConfiguration<RendererType.SVG>;
62
+ }
63
+
34
64
  type AnimateOnScroll = boolean | '' | null;
35
65
  type Autoplay = boolean | '' | 'autoplay' | null;
36
66
  type Controls = boolean | '' | 'controls' | null;
@@ -40,7 +70,7 @@ declare global {
40
70
  interface HTMLElementTagNameMap {
41
71
  [tagName]: DotLottiePlayer | DotLottiePlayerLight;
42
72
  }
43
- function dotLottiePlayer(): DotLottiePlayer | DotLottiePlayerLight;
73
+ function dotLottiePlayer(): DotLottiePlayer | DotLottiePlayerLight | DotLottiePlayerSVG | DotLottiePlayerCanvas;
44
74
  }
45
75
  type JSXLottiePlayer = Omit<Partial<DotLottiePlayer | DotLottiePlayerLight>, 'style'> & {
46
76
  class?: string;
package/dist/full.js CHANGED
@@ -1167,7 +1167,12 @@ const notImplemented = 'Method is not implemented';
1167
1167
  if (!this.animateOnScroll && this.playerState === PlayerState.Frozen) {
1168
1168
  this.play();
1169
1169
  }
1170
- if (!this._playerState.scrollY) {
1170
+ /**
1171
+ * If the player is a ways down the page, we need to account for this by
1172
+ * setting _playerState.scrollY to the current scroll position. However, we
1173
+ * also need to check that the player hasn't been scrolled past, so we check
1174
+ * boundingClientRect as well.
1175
+ */ if (!this._playerState.scrollY && (entries[i]?.boundingClientRect.y || 0) > 0) {
1171
1176
  this._playerState.scrollY = scrollY;
1172
1177
  }
1173
1178
  this._playerState.visible = true;
package/dist/light.d.ts CHANGED
@@ -4,6 +4,8 @@ import * as _aarsteinmedia_lottie_web_light from '@aarsteinmedia/lottie-web/ligh
4
4
  import * as _aarsteinmedia_lottie_web from '@aarsteinmedia/lottie-web';
5
5
  import { Vector2, AnimationConfiguration, AnimationData, AnimationDirection, AddAnimationParams, Result, ConvertParams, AnimationItem, LottieManifest, AnimationSettings } from '@aarsteinmedia/lottie-web';
6
6
  import { addAnimation, convert } from '@aarsteinmedia/lottie-web/dotlottie';
7
+ import * as _aarsteinmedia_lottie_web_canvas from '@aarsteinmedia/lottie-web/canvas';
8
+ import * as _aarsteinmedia_lottie_web_svg from '@aarsteinmedia/lottie-web/svg';
7
9
 
8
10
  declare class DotLottiePlayer extends DotLottiePlayerBase {
9
11
  addAnimation: typeof addAnimation;
@@ -31,6 +33,34 @@ declare enum PlayerState {
31
33
  }
32
34
  declare const tagName = "dotlottie-player";
33
35
 
36
+ declare class DotLottiePlayerCanvas extends DotLottiePlayerBase {
37
+ loadAnimation: typeof _aarsteinmedia_lottie_web_canvas.loadAnimation;
38
+ get renderer(): RendererType;
39
+ constructor();
40
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
41
+ container?: HTMLElement;
42
+ rendererType: RendererType;
43
+ initialSegment?: Vector2;
44
+ hasAutoplay: boolean;
45
+ hasLoop: boolean;
46
+ preserveAspectRatio: PreserveAspectRatio;
47
+ }): AnimationConfiguration<RendererType.Canvas>;
48
+ }
49
+
50
+ declare class DotLottiePlayerSVG extends DotLottiePlayerBase {
51
+ loadAnimation: typeof _aarsteinmedia_lottie_web_svg.loadAnimation;
52
+ get renderer(): RendererType;
53
+ constructor();
54
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
55
+ container?: HTMLElement;
56
+ rendererType: RendererType;
57
+ initialSegment?: Vector2;
58
+ hasAutoplay: boolean;
59
+ hasLoop: boolean;
60
+ preserveAspectRatio: PreserveAspectRatio;
61
+ }): AnimationConfiguration<RendererType.SVG>;
62
+ }
63
+
34
64
  type AnimateOnScroll = boolean | '' | null;
35
65
  type Autoplay = boolean | '' | 'autoplay' | null;
36
66
  type Controls = boolean | '' | 'controls' | null;
@@ -40,7 +70,7 @@ declare global {
40
70
  interface HTMLElementTagNameMap {
41
71
  [tagName]: DotLottiePlayer | DotLottiePlayerLight;
42
72
  }
43
- function dotLottiePlayer(): DotLottiePlayer | DotLottiePlayerLight;
73
+ function dotLottiePlayer(): DotLottiePlayer | DotLottiePlayerLight | DotLottiePlayerSVG | DotLottiePlayerCanvas;
44
74
  }
45
75
  type JSXLottiePlayer = Omit<Partial<DotLottiePlayer | DotLottiePlayerLight>, 'style'> & {
46
76
  class?: string;
package/dist/light.js CHANGED
@@ -1167,7 +1167,12 @@ const notImplemented = 'Method is not implemented';
1167
1167
  if (!this.animateOnScroll && this.playerState === PlayerState.Frozen) {
1168
1168
  this.play();
1169
1169
  }
1170
- if (!this._playerState.scrollY) {
1170
+ /**
1171
+ * If the player is a ways down the page, we need to account for this by
1172
+ * setting _playerState.scrollY to the current scroll position. However, we
1173
+ * also need to check that the player hasn't been scrolled past, so we check
1174
+ * boundingClientRect as well.
1175
+ */ if (!this._playerState.scrollY && (entries[i]?.boundingClientRect.y || 0) > 0) {
1171
1176
  this._playerState.scrollY = scrollY;
1172
1177
  }
1173
1178
  this._playerState.visible = true;
package/dist/svg.d.ts ADDED
@@ -0,0 +1,265 @@
1
+ import { RendererType, PreserveAspectRatio, PlayMode } from '@aarsteinmedia/lottie-web/utils';
2
+ export { PlayMode, PlayerEvents } from '@aarsteinmedia/lottie-web/utils';
3
+ import * as _aarsteinmedia_lottie_web_svg from '@aarsteinmedia/lottie-web/svg';
4
+ import * as _aarsteinmedia_lottie_web from '@aarsteinmedia/lottie-web';
5
+ import { Vector2, AnimationConfiguration, AnimationData, AnimationDirection, AddAnimationParams, Result, ConvertParams, AnimationItem, LottieManifest, AnimationSettings } from '@aarsteinmedia/lottie-web';
6
+ import { addAnimation, convert } from '@aarsteinmedia/lottie-web/dotlottie';
7
+ import * as _aarsteinmedia_lottie_web_light from '@aarsteinmedia/lottie-web/light';
8
+ import * as _aarsteinmedia_lottie_web_canvas from '@aarsteinmedia/lottie-web/canvas';
9
+
10
+ declare class DotLottiePlayer extends DotLottiePlayerBase {
11
+ addAnimation: typeof addAnimation;
12
+ convert: typeof convert;
13
+ loadAnimation: typeof _aarsteinmedia_lottie_web.loadAnimation;
14
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, rendererType }: {
15
+ container?: HTMLElement;
16
+ rendererType: RendererType;
17
+ initialSegment?: Vector2;
18
+ hasAutoplay: boolean;
19
+ hasLoop: boolean;
20
+ preserveAspectRatio: PreserveAspectRatio;
21
+ }): AnimationConfiguration<RendererType>;
22
+ }
23
+
24
+ declare class DotLottiePlayerLight extends DotLottiePlayerBase {
25
+ loadAnimation: typeof _aarsteinmedia_lottie_web_light.loadAnimation;
26
+ get renderer(): RendererType;
27
+ constructor();
28
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
29
+ container?: HTMLElement;
30
+ rendererType: RendererType;
31
+ initialSegment?: Vector2;
32
+ hasAutoplay: boolean;
33
+ hasLoop: boolean;
34
+ preserveAspectRatio: PreserveAspectRatio;
35
+ }): AnimationConfiguration<RendererType.SVG>;
36
+ }
37
+
38
+ declare enum PlayerState {
39
+ Completed = "completed",
40
+ Destroyed = "destroyed",
41
+ Error = "error",
42
+ Frozen = "frozen",
43
+ Loading = "loading",
44
+ Paused = "paused",
45
+ Playing = "playing",
46
+ Stopped = "stopped"
47
+ }
48
+ declare const tagName = "dotlottie-player";
49
+
50
+ declare class DotLottiePlayerCanvas extends DotLottiePlayerBase {
51
+ loadAnimation: typeof _aarsteinmedia_lottie_web_canvas.loadAnimation;
52
+ get renderer(): RendererType;
53
+ constructor();
54
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
55
+ container?: HTMLElement;
56
+ rendererType: RendererType;
57
+ initialSegment?: Vector2;
58
+ hasAutoplay: boolean;
59
+ hasLoop: boolean;
60
+ preserveAspectRatio: PreserveAspectRatio;
61
+ }): AnimationConfiguration<RendererType.Canvas>;
62
+ }
63
+
64
+ type AnimateOnScroll = boolean | '' | null;
65
+ type Autoplay = boolean | '' | 'autoplay' | null;
66
+ type Controls = boolean | '' | 'controls' | null;
67
+ type Loop = boolean | '' | 'loop' | null;
68
+ type Subframe = boolean | '' | null;
69
+ declare global {
70
+ interface HTMLElementTagNameMap {
71
+ [tagName]: DotLottiePlayer | DotLottiePlayerLight;
72
+ }
73
+ function dotLottiePlayer(): DotLottiePlayer | DotLottiePlayerLight | DotLottiePlayerSVG | DotLottiePlayerCanvas;
74
+ }
75
+ type JSXLottiePlayer = Omit<Partial<DotLottiePlayer | DotLottiePlayerLight>, 'style'> & {
76
+ class?: string;
77
+ ref?: React.RefObject<unknown>;
78
+ style?: React.CSSProperties;
79
+ src: string;
80
+ };
81
+ declare module 'react' {
82
+ namespace JSX {
83
+ interface IntrinsicElements {
84
+ [tagName]: JSXLottiePlayer;
85
+ }
86
+ }
87
+ }
88
+ declare module 'react/jsx-runtime' {
89
+ namespace JSX {
90
+ interface IntrinsicElements {
91
+ [tagName]: JSXLottiePlayer;
92
+ }
93
+ }
94
+ }
95
+ declare module 'react/jsx-dev-runtime' {
96
+ namespace JSX {
97
+ interface IntrinsicElements {
98
+ [tagName]: JSXLottiePlayer;
99
+ }
100
+ }
101
+ }
102
+
103
+ declare abstract class PropertyCallbackElement extends HTMLElement {
104
+ constructor();
105
+ connectedCallback(): void;
106
+ propertyChangedCallback(_name: string, _oldValue: unknown, _value: unknown): void;
107
+ }
108
+
109
+ declare function renderControls(this: DotLottiePlayerBase): void;
110
+
111
+ declare function renderPlayer(this: DotLottiePlayerBase): Promise<void>;
112
+
113
+ declare abstract class DotLottiePlayerBase extends PropertyCallbackElement {
114
+ static get observedAttributes(): string[];
115
+ static get observedProperties(): string[];
116
+ static get styles(): () => Promise<CSSStyleSheet>;
117
+ isLight: boolean;
118
+ playerState: PlayerState;
119
+ shadow: ShadowRoot | undefined;
120
+ source?: string;
121
+ template?: HTMLTemplateElement;
122
+ set animateOnScroll(value: AnimateOnScroll);
123
+ get animateOnScroll(): AnimateOnScroll;
124
+ get animations(): AnimationData[];
125
+ set autoplay(value: Autoplay);
126
+ get autoplay(): Autoplay;
127
+ set background(value: string);
128
+ get background(): string;
129
+ set controls(value: Controls);
130
+ get controls(): Controls;
131
+ set count(value: number);
132
+ get count(): number;
133
+ get currentAnimation(): number;
134
+ set description(value: string | null);
135
+ get description(): string | null;
136
+ set direction(value: AnimationDirection);
137
+ get direction(): AnimationDirection;
138
+ set dontFreezeOnBlur(value: boolean);
139
+ get dontFreezeOnBlur(): boolean;
140
+ set hover(value: boolean);
141
+ get hover(): boolean;
142
+ set intermission(value: number);
143
+ get intermission(): number;
144
+ get isDotLottie(): boolean;
145
+ set loop(value: Loop);
146
+ get loop(): Loop;
147
+ set mode(value: PlayMode);
148
+ get mode(): PlayMode;
149
+ set objectfit(value: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down');
150
+ get objectfit(): "contain" | "cover" | "fill" | "none" | "scale-down";
151
+ set preserveAspectRatio(value: PreserveAspectRatio | null);
152
+ get preserveAspectRatio(): PreserveAspectRatio | null;
153
+ set renderer(value: RendererType);
154
+ get renderer(): RendererType;
155
+ set simple(value: boolean);
156
+ get simple(): boolean;
157
+ set speed(value: number);
158
+ get speed(): number;
159
+ set src(value: string | null);
160
+ get src(): string | null;
161
+ set subframe(value: Subframe);
162
+ get subframe(): Subframe;
163
+ protected _container: HTMLElement | null;
164
+ protected _errorMessage: string;
165
+ protected _identifier: string;
166
+ protected _isSettingsOpen: boolean;
167
+ protected _playerState: {
168
+ prev: PlayerState;
169
+ count: number;
170
+ loaded: boolean;
171
+ visible: boolean;
172
+ scrollY: number;
173
+ scrollTimeout: NodeJS.Timeout | null;
174
+ };
175
+ protected _render: typeof renderPlayer;
176
+ protected _renderControls: typeof renderControls;
177
+ protected _seeker: number;
178
+ private _animations;
179
+ private _currentAnimation;
180
+ private _intersectionObserver?;
181
+ private _isBounce;
182
+ private _isDotLottie;
183
+ private _lottieInstance;
184
+ private _manifest?;
185
+ private _multiAnimationSettings;
186
+ private _segment?;
187
+ constructor();
188
+ addAnimation(_params: AddAnimationParams): Promise<Result>;
189
+ attributeChangedCallback(name: string, _oldValue: unknown, value: string): Promise<void>;
190
+ connectedCallback(): void;
191
+ convert(_params: ConvertParams): Promise<Result>;
192
+ destroy(): void;
193
+ disconnectedCallback(): void;
194
+ getLottie(): AnimationItem | null;
195
+ getManifest(): LottieManifest | undefined;
196
+ getMultiAnimationSettings(): AnimationSettings[];
197
+ getSegment(): Vector2 | undefined;
198
+ load(src: string | null): Promise<void>;
199
+ loadAnimation(_config: AnimationConfiguration): AnimationItem;
200
+ next(): void;
201
+ pause(): void;
202
+ play(): void;
203
+ prev(): void;
204
+ propertyChangedCallback(name: string, _oldValue: unknown, value: unknown): void;
205
+ reload(): Promise<void>;
206
+ seek(value: number | string): void;
207
+ setCount(value: number): void;
208
+ setDirection(value: AnimationDirection): void;
209
+ setLoop(value: boolean): void;
210
+ setMultiAnimationSettings(settings: AnimationSettings[]): void;
211
+ setSegment(segment: Vector2): void;
212
+ setSpeed(value?: number): void;
213
+ setSubframe(value: boolean): void;
214
+ snapshot(shouldDownload?: boolean, name?: string): string | null;
215
+ stop(): void;
216
+ toggleBoomerang(): void;
217
+ toggleLoop(): void;
218
+ togglePlay(): void;
219
+ protected _freeze(): void;
220
+ protected _handleBlur(): void;
221
+ protected _handleSeekChange({ target }: Event): void;
222
+ protected _handleSettingsClick({ target }: Event): void;
223
+ protected setOptions(_options: {
224
+ container?: HTMLElement;
225
+ rendererType: RendererType;
226
+ initialSegment?: Vector2;
227
+ hasAutoplay: boolean;
228
+ hasLoop: boolean;
229
+ preserveAspectRatio: PreserveAspectRatio;
230
+ }): AnimationConfiguration<RendererType.SVG | RendererType.Canvas | RendererType.HTML>;
231
+ private _addEventListeners;
232
+ private _addIntersectionObserver;
233
+ private _complete;
234
+ private _dataFailed;
235
+ private _dataReady;
236
+ private _DOMLoaded;
237
+ private _enterFrame;
238
+ private _getOptions;
239
+ private _handleScroll;
240
+ private _handleWindowBlur;
241
+ private _loopComplete;
242
+ private _mouseEnter;
243
+ private _mouseLeave;
244
+ private _onVisibilityChange;
245
+ private _removeEventListeners;
246
+ private _switchInstance;
247
+ private _toggleEventListeners;
248
+ private _toggleSettings;
249
+ }
250
+
251
+ declare class DotLottiePlayerSVG extends DotLottiePlayerBase {
252
+ loadAnimation: typeof _aarsteinmedia_lottie_web_svg.loadAnimation;
253
+ get renderer(): RendererType;
254
+ constructor();
255
+ protected setOptions({ container, hasAutoplay, hasLoop, initialSegment, preserveAspectRatio, }: {
256
+ container?: HTMLElement;
257
+ rendererType: RendererType;
258
+ initialSegment?: Vector2;
259
+ hasAutoplay: boolean;
260
+ hasLoop: boolean;
261
+ preserveAspectRatio: PreserveAspectRatio;
262
+ }): AnimationConfiguration<RendererType.SVG>;
263
+ }
264
+
265
+ export { PlayerState, DotLottiePlayerSVG as default, tagName };