@aarsteinmedia/dotlottie-player 2.2.0 → 2.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/dist/cjs/index.js +18 -7
- package/dist/custom-elements.json +31 -0
- package/dist/esm/index.js +18 -7
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -299,7 +299,7 @@ const addExt = (ext, str)=>{
|
|
|
299
299
|
};
|
|
300
300
|
|
|
301
301
|
var name = "@aarsteinmedia/dotlottie-player";
|
|
302
|
-
var version = "2.2.
|
|
302
|
+
var version = "2.2.1";
|
|
303
303
|
var description = "Web Component for playing Lottie animations in your web app. Previously @johanaarstein/dotlottie-player";
|
|
304
304
|
var exports$1 = {
|
|
305
305
|
".": {
|
|
@@ -430,7 +430,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
430
430
|
}
|
|
431
431
|
class DotLottiePlayer extends lit.LitElement {
|
|
432
432
|
_getOptions() {
|
|
433
|
-
const preserveAspectRatio = this.preserveAspectRatio ?? (this.objectfit && aspectRatio(this.objectfit)),
|
|
433
|
+
const preserveAspectRatio = this.preserveAspectRatio ?? (this.objectfit && aspectRatio(this.objectfit)), currentAnimationSettings = this.multiAnimationSettings?.[this._currentAnimation], currentAnimationManifest = this._manifest.animations[this._currentAnimation], loop = currentAnimationSettings?.loop !== undefined ? !!currentAnimationSettings.loop : this.loop !== undefined ? !!this.loop : currentAnimationManifest.loop !== undefined && !!currentAnimationManifest.loop, autoplay = currentAnimationSettings?.autoplay !== undefined ? !!currentAnimationSettings.autoplay : this.autoplay !== undefined ? !!this.autoplay : currentAnimationManifest.autoplay !== undefined && !!currentAnimationManifest.autoplay, initialSegment = !this.segment || this.segment.some((val)=>val < 0) ? undefined : this.segment.every((val)=>val > 0) ? [
|
|
434
434
|
this.segment[0] - 1,
|
|
435
435
|
this.segment[1] - 1
|
|
436
436
|
] : this.segment, options = {
|
|
@@ -501,8 +501,9 @@ class DotLottiePlayer extends lit.LitElement {
|
|
|
501
501
|
return;
|
|
502
502
|
}
|
|
503
503
|
this._addEventListeners();
|
|
504
|
-
this.
|
|
505
|
-
this.
|
|
504
|
+
const speed = this.multiAnimationSettings?.[this._currentAnimation]?.speed ?? this.speed ?? this._manifest.animations[this._currentAnimation].speed, direction = this.multiAnimationSettings?.[this._currentAnimation]?.direction ?? this.direction ?? this._manifest.animations[this._currentAnimation].direction ?? 1;
|
|
505
|
+
this.setSpeed(speed);
|
|
506
|
+
this.setDirection(direction);
|
|
506
507
|
this.setSubframe(!!this.subframe);
|
|
507
508
|
if (this.autoplay) {
|
|
508
509
|
if (this.direction === -1) this.seek('99%');
|
|
@@ -537,9 +538,9 @@ class DotLottiePlayer extends lit.LitElement {
|
|
|
537
538
|
if (!this._lottieInstance) {
|
|
538
539
|
return;
|
|
539
540
|
}
|
|
540
|
-
const { firstFrame, totalFrames, playDirection } = this._lottieInstance;
|
|
541
|
+
const { firstFrame, totalFrames, playDirection } = this._lottieInstance, isBounce = this.mode === exports.PlayMode.Bounce || this._manifest.animations[this._currentAnimation].mode === exports.PlayMode.Bounce;
|
|
541
542
|
if (this.count) {
|
|
542
|
-
|
|
543
|
+
isBounce ? this._playerState.count += 1 : this._playerState.count += 0.5;
|
|
543
544
|
if (this._playerState.count >= this.count) {
|
|
544
545
|
this.setLooping(false);
|
|
545
546
|
this.currentState = exports.PlayerState.Completed;
|
|
@@ -548,7 +549,7 @@ class DotLottiePlayer extends lit.LitElement {
|
|
|
548
549
|
}
|
|
549
550
|
}
|
|
550
551
|
this.dispatchEvent(new CustomEvent(exports.PlayerEvents.Loop));
|
|
551
|
-
if (
|
|
552
|
+
if (isBounce) {
|
|
552
553
|
this._lottieInstance?.goToAndStop(playDirection === -1 ? firstFrame : totalFrames * 0.99, true);
|
|
553
554
|
this._lottieInstance?.setDirection(playDirection * -1);
|
|
554
555
|
return setTimeout(()=>{
|
|
@@ -760,6 +761,11 @@ class DotLottiePlayer extends lit.LitElement {
|
|
|
760
761
|
this._lottieInstance.setLoop(value);
|
|
761
762
|
}
|
|
762
763
|
}
|
|
764
|
+
setMultiAnimationSettings(settings) {
|
|
765
|
+
if (this._lottieInstance) {
|
|
766
|
+
this.multiAnimationSettings = settings;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
763
769
|
togglePlay() {
|
|
764
770
|
if (!this._lottieInstance) return;
|
|
765
771
|
const { currentFrame, playDirection, totalFrames } = this._lottieInstance;
|
|
@@ -965,6 +971,11 @@ _ts_decorate([
|
|
|
965
971
|
type: String
|
|
966
972
|
})
|
|
967
973
|
], DotLottiePlayer.prototype, "mode", void 0);
|
|
974
|
+
_ts_decorate([
|
|
975
|
+
decorators_js.property({
|
|
976
|
+
type: Array
|
|
977
|
+
})
|
|
978
|
+
], DotLottiePlayer.prototype, "multiAnimationSettings", void 0);
|
|
968
979
|
_ts_decorate([
|
|
969
980
|
decorators_js.property({
|
|
970
981
|
type: String
|
|
@@ -158,6 +158,15 @@
|
|
|
158
158
|
"description": "Play mode",
|
|
159
159
|
"attribute": "mode"
|
|
160
160
|
},
|
|
161
|
+
{
|
|
162
|
+
"kind": "field",
|
|
163
|
+
"name": "multiAnimationSettings",
|
|
164
|
+
"type": {
|
|
165
|
+
"text": "Partial<Animations> | undefined"
|
|
166
|
+
},
|
|
167
|
+
"description": "Multi-animation settings\nIf set, these will override conflicting settings",
|
|
168
|
+
"attribute": "multiAnimationSettings"
|
|
169
|
+
},
|
|
161
170
|
{
|
|
162
171
|
"kind": "field",
|
|
163
172
|
"name": "objectfit",
|
|
@@ -569,6 +578,20 @@
|
|
|
569
578
|
],
|
|
570
579
|
"description": "Set loop"
|
|
571
580
|
},
|
|
581
|
+
{
|
|
582
|
+
"kind": "method",
|
|
583
|
+
"name": "setMultiAnimationSettings",
|
|
584
|
+
"privacy": "public",
|
|
585
|
+
"parameters": [
|
|
586
|
+
{
|
|
587
|
+
"name": "settings",
|
|
588
|
+
"type": {
|
|
589
|
+
"text": "Partial<Animations>"
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
],
|
|
593
|
+
"description": "Set Multi-animation settings"
|
|
594
|
+
},
|
|
572
595
|
{
|
|
573
596
|
"kind": "method",
|
|
574
597
|
"name": "togglePlay",
|
|
@@ -786,6 +809,14 @@
|
|
|
786
809
|
"description": "Play mode",
|
|
787
810
|
"fieldName": "mode"
|
|
788
811
|
},
|
|
812
|
+
{
|
|
813
|
+
"name": "multiAnimationSettings",
|
|
814
|
+
"type": {
|
|
815
|
+
"text": "Partial<Animations> | undefined"
|
|
816
|
+
},
|
|
817
|
+
"description": "Multi-animation settings\nIf set, these will override conflicting settings",
|
|
818
|
+
"fieldName": "multiAnimationSettings"
|
|
819
|
+
},
|
|
789
820
|
{
|
|
790
821
|
"name": "objectfit",
|
|
791
822
|
"type": {
|
package/dist/esm/index.js
CHANGED
|
@@ -297,7 +297,7 @@ const addExt = (ext, str)=>{
|
|
|
297
297
|
};
|
|
298
298
|
|
|
299
299
|
var name = "@aarsteinmedia/dotlottie-player";
|
|
300
|
-
var version = "2.2.
|
|
300
|
+
var version = "2.2.1";
|
|
301
301
|
var description = "Web Component for playing Lottie animations in your web app. Previously @johanaarstein/dotlottie-player";
|
|
302
302
|
var exports = {
|
|
303
303
|
".": {
|
|
@@ -428,7 +428,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
428
428
|
}
|
|
429
429
|
class DotLottiePlayer extends LitElement {
|
|
430
430
|
_getOptions() {
|
|
431
|
-
const preserveAspectRatio = this.preserveAspectRatio ?? (this.objectfit && aspectRatio(this.objectfit)),
|
|
431
|
+
const preserveAspectRatio = this.preserveAspectRatio ?? (this.objectfit && aspectRatio(this.objectfit)), currentAnimationSettings = this.multiAnimationSettings?.[this._currentAnimation], currentAnimationManifest = this._manifest.animations[this._currentAnimation], loop = currentAnimationSettings?.loop !== undefined ? !!currentAnimationSettings.loop : this.loop !== undefined ? !!this.loop : currentAnimationManifest.loop !== undefined && !!currentAnimationManifest.loop, autoplay = currentAnimationSettings?.autoplay !== undefined ? !!currentAnimationSettings.autoplay : this.autoplay !== undefined ? !!this.autoplay : currentAnimationManifest.autoplay !== undefined && !!currentAnimationManifest.autoplay, initialSegment = !this.segment || this.segment.some((val)=>val < 0) ? undefined : this.segment.every((val)=>val > 0) ? [
|
|
432
432
|
this.segment[0] - 1,
|
|
433
433
|
this.segment[1] - 1
|
|
434
434
|
] : this.segment, options = {
|
|
@@ -499,8 +499,9 @@ class DotLottiePlayer extends LitElement {
|
|
|
499
499
|
return;
|
|
500
500
|
}
|
|
501
501
|
this._addEventListeners();
|
|
502
|
-
this.
|
|
503
|
-
this.
|
|
502
|
+
const speed = this.multiAnimationSettings?.[this._currentAnimation]?.speed ?? this.speed ?? this._manifest.animations[this._currentAnimation].speed, direction = this.multiAnimationSettings?.[this._currentAnimation]?.direction ?? this.direction ?? this._manifest.animations[this._currentAnimation].direction ?? 1;
|
|
503
|
+
this.setSpeed(speed);
|
|
504
|
+
this.setDirection(direction);
|
|
504
505
|
this.setSubframe(!!this.subframe);
|
|
505
506
|
if (this.autoplay) {
|
|
506
507
|
if (this.direction === -1) this.seek('99%');
|
|
@@ -535,9 +536,9 @@ class DotLottiePlayer extends LitElement {
|
|
|
535
536
|
if (!this._lottieInstance) {
|
|
536
537
|
return;
|
|
537
538
|
}
|
|
538
|
-
const { firstFrame, totalFrames, playDirection } = this._lottieInstance;
|
|
539
|
+
const { firstFrame, totalFrames, playDirection } = this._lottieInstance, isBounce = this.mode === PlayMode.Bounce || this._manifest.animations[this._currentAnimation].mode === PlayMode.Bounce;
|
|
539
540
|
if (this.count) {
|
|
540
|
-
|
|
541
|
+
isBounce ? this._playerState.count += 1 : this._playerState.count += 0.5;
|
|
541
542
|
if (this._playerState.count >= this.count) {
|
|
542
543
|
this.setLooping(false);
|
|
543
544
|
this.currentState = PlayerState.Completed;
|
|
@@ -546,7 +547,7 @@ class DotLottiePlayer extends LitElement {
|
|
|
546
547
|
}
|
|
547
548
|
}
|
|
548
549
|
this.dispatchEvent(new CustomEvent(PlayerEvents.Loop));
|
|
549
|
-
if (
|
|
550
|
+
if (isBounce) {
|
|
550
551
|
this._lottieInstance?.goToAndStop(playDirection === -1 ? firstFrame : totalFrames * 0.99, true);
|
|
551
552
|
this._lottieInstance?.setDirection(playDirection * -1);
|
|
552
553
|
return setTimeout(()=>{
|
|
@@ -758,6 +759,11 @@ class DotLottiePlayer extends LitElement {
|
|
|
758
759
|
this._lottieInstance.setLoop(value);
|
|
759
760
|
}
|
|
760
761
|
}
|
|
762
|
+
setMultiAnimationSettings(settings) {
|
|
763
|
+
if (this._lottieInstance) {
|
|
764
|
+
this.multiAnimationSettings = settings;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
761
767
|
togglePlay() {
|
|
762
768
|
if (!this._lottieInstance) return;
|
|
763
769
|
const { currentFrame, playDirection, totalFrames } = this._lottieInstance;
|
|
@@ -963,6 +969,11 @@ _ts_decorate([
|
|
|
963
969
|
type: String
|
|
964
970
|
})
|
|
965
971
|
], DotLottiePlayer.prototype, "mode", void 0);
|
|
972
|
+
_ts_decorate([
|
|
973
|
+
property({
|
|
974
|
+
type: Array
|
|
975
|
+
})
|
|
976
|
+
], DotLottiePlayer.prototype, "multiAnimationSettings", void 0);
|
|
966
977
|
_ts_decorate([
|
|
967
978
|
property({
|
|
968
979
|
type: String
|
package/dist/index.d.ts
CHANGED
|
@@ -38,8 +38,9 @@ interface Config {
|
|
|
38
38
|
mode?: PlayMode;
|
|
39
39
|
speed?: number;
|
|
40
40
|
}
|
|
41
|
+
type Animations = Omit<Config, 'url'>[];
|
|
41
42
|
interface LottieManifest {
|
|
42
|
-
animations:
|
|
43
|
+
animations: Animations;
|
|
43
44
|
author?: string;
|
|
44
45
|
description?: string;
|
|
45
46
|
generator?: string;
|
|
@@ -111,6 +112,7 @@ declare class DotLottiePlayer extends LitElement {
|
|
|
111
112
|
intermission?: number | undefined;
|
|
112
113
|
loop?: Loop;
|
|
113
114
|
mode?: PlayMode;
|
|
115
|
+
multiAnimationSettings?: Partial<Animations>;
|
|
114
116
|
objectfit?: ObjectFit;
|
|
115
117
|
preserveAspectRatio?: PreserveAspectRatio;
|
|
116
118
|
renderer?: RendererType;
|
|
@@ -152,6 +154,7 @@ declare class DotLottiePlayer extends LitElement {
|
|
|
152
154
|
setSpeed(value?: number): void;
|
|
153
155
|
setDirection(value: AnimationDirection): void;
|
|
154
156
|
setLooping(value: boolean): void;
|
|
157
|
+
setMultiAnimationSettings(settings: Partial<Animations>): void;
|
|
155
158
|
togglePlay(): void;
|
|
156
159
|
toggleLooping(): void;
|
|
157
160
|
toggleBoomerang(): void;
|