@aarsteinmedia/dotlottie-player 6.0.5 → 6.1.0
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/CHANGELOG.md +11 -0
- package/README.md +7 -0
- package/dist/canvas.d.ts +14 -2
- package/dist/canvas.js +287 -94
- package/dist/full.d.ts +14 -2
- package/dist/full.js +287 -94
- package/dist/light.d.ts +14 -2
- package/dist/light.js +287 -94
- package/dist/svg.d.ts +14 -2
- package/dist/svg.js +287 -94
- package/dist/unpkg-canvas.js +9 -9
- package/dist/unpkg-full.js +8 -8
- package/dist/unpkg-light.js +5 -5
- package/dist/unpkg-svg.js +8 -8
- package/package.json +16 -15
package/dist/svg.js
CHANGED
|
@@ -303,7 +303,7 @@ const pauseIcon = /* HTML */ `
|
|
|
303
303
|
'h'
|
|
304
304
|
];
|
|
305
305
|
return mandatory.every((field)=>Object.hasOwn(json, field));
|
|
306
|
-
}, frameOutput = (frame)=>((frame ?? 0) + 1).toString().padStart(3, '0');
|
|
306
|
+
}, isTouch = ()=>'ontouchstart' in window, frameOutput = (frame)=>((frame ?? 0) + 1).toString().padStart(3, '0');
|
|
307
307
|
|
|
308
308
|
const notImplemented = 'Method is not implemented';
|
|
309
309
|
/**
|
|
@@ -319,7 +319,10 @@ const notImplemented = 'Method is not implemented';
|
|
|
319
319
|
'direction',
|
|
320
320
|
'hover',
|
|
321
321
|
'loop',
|
|
322
|
+
// 'mouseout',
|
|
322
323
|
'mode',
|
|
324
|
+
'playOnClick',
|
|
325
|
+
'playOnVisible',
|
|
323
326
|
'speed',
|
|
324
327
|
'src',
|
|
325
328
|
'subframe'
|
|
@@ -397,6 +400,18 @@ const notImplemented = 'Method is not implemented';
|
|
|
397
400
|
return this._currentAnimation;
|
|
398
401
|
}
|
|
399
402
|
/**
|
|
403
|
+
* Delay playback on playOnVisible.
|
|
404
|
+
*/ set delay(value) {
|
|
405
|
+
this.setAttribute('delay', value.toString());
|
|
406
|
+
}
|
|
407
|
+
get delay() {
|
|
408
|
+
const val = this.getAttribute('delay');
|
|
409
|
+
if (val) {
|
|
410
|
+
return Number(val);
|
|
411
|
+
}
|
|
412
|
+
return 0;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
400
415
|
* Description for screen readers.
|
|
401
416
|
*/ set description(value) {
|
|
402
417
|
if (value) {
|
|
@@ -473,6 +488,26 @@ const notImplemented = 'Method is not implemented';
|
|
|
473
488
|
return PlayMode.Normal;
|
|
474
489
|
}
|
|
475
490
|
/**
|
|
491
|
+
* Action on mouseout.
|
|
492
|
+
*/ set mouseout(value) {
|
|
493
|
+
this.setAttribute('mouseout', value);
|
|
494
|
+
}
|
|
495
|
+
get mouseout() {
|
|
496
|
+
const val = this.getAttribute('mouseout');
|
|
497
|
+
switch(val){
|
|
498
|
+
case 'void':
|
|
499
|
+
case 'pause':
|
|
500
|
+
case 'reverse':
|
|
501
|
+
{
|
|
502
|
+
return val;
|
|
503
|
+
}
|
|
504
|
+
default:
|
|
505
|
+
{
|
|
506
|
+
return 'stop';
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
476
511
|
* Resizing to container.
|
|
477
512
|
*/ set objectfit(value) {
|
|
478
513
|
this.setAttribute('objectfit', value);
|
|
@@ -485,6 +520,34 @@ const notImplemented = 'Method is not implemented';
|
|
|
485
520
|
return ObjectFit.Contain;
|
|
486
521
|
}
|
|
487
522
|
/**
|
|
523
|
+
* Whether to play once or reset,
|
|
524
|
+
* if playOnVisible is true.
|
|
525
|
+
*/ set once(value) {
|
|
526
|
+
this.setAttribute('once', value.toString());
|
|
527
|
+
}
|
|
528
|
+
get once() {
|
|
529
|
+
const val = this.getAttribute('once');
|
|
530
|
+
return val === 'true' || val === '' || val === '1';
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Whether to toggle play on click.
|
|
534
|
+
*/ set playOnClick(value) {
|
|
535
|
+
this.setAttribute('playOnClick', value.toString());
|
|
536
|
+
}
|
|
537
|
+
get playOnClick() {
|
|
538
|
+
const val = this.getAttribute('playOnClick');
|
|
539
|
+
return val === 'true' || val === '' || val === '1';
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Play when visible.
|
|
543
|
+
*/ set playOnVisible(value) {
|
|
544
|
+
this.setAttribute('playOnVisible', value.toString());
|
|
545
|
+
}
|
|
546
|
+
get playOnVisible() {
|
|
547
|
+
const val = this.getAttribute('playOnVisible');
|
|
548
|
+
return val === 'true' || val === '' || val === '1';
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
488
551
|
* Resizing to container (Deprecated).
|
|
489
552
|
*/ set preserveAspectRatio(value) {
|
|
490
553
|
this.setAttribute('preserveAspectRatio', value || PreserveAspectRatio.Contain);
|
|
@@ -578,6 +641,7 @@ const notImplemented = 'Method is not implemented';
|
|
|
578
641
|
this._enterFrame = this._enterFrame.bind(this);
|
|
579
642
|
this._freeze = this._freeze.bind(this);
|
|
580
643
|
this._handleBlur = this._handleBlur.bind(this);
|
|
644
|
+
this._handleClick = this._handleClick.bind(this);
|
|
581
645
|
this._handleScroll = this._handleScroll.bind(this);
|
|
582
646
|
this._handleSeekChange = this._handleSeekChange.bind(this);
|
|
583
647
|
this._handleWindowBlur = this._handleWindowBlur.bind(this);
|
|
@@ -607,74 +671,113 @@ const notImplemented = 'Method is not implemented';
|
|
|
607
671
|
/**
|
|
608
672
|
* Runs when the value of an attribute is changed on the component.
|
|
609
673
|
*/ async attributeChangedCallback(name, _oldValue, value) {
|
|
610
|
-
if (!this._lottieInstance || !this.shadow) {
|
|
674
|
+
if (!this._lottieInstance || !this.shadow || !this._container) {
|
|
611
675
|
return;
|
|
612
676
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
677
|
+
switch(name){
|
|
678
|
+
case 'animateOnScroll':
|
|
679
|
+
{
|
|
680
|
+
if (value === '' || Boolean(value)) {
|
|
681
|
+
this._lottieInstance.autoplay = false;
|
|
682
|
+
addEventListener('scroll', this._handleScroll, {
|
|
683
|
+
capture: true,
|
|
684
|
+
passive: true
|
|
685
|
+
});
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
removeEventListener('scroll', this._handleScroll, true);
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
case 'autoplay':
|
|
692
|
+
{
|
|
693
|
+
if (this.animateOnScroll || this.playOnVisible) {
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (value === '' || Boolean(value)) {
|
|
697
|
+
this.play();
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
this.stop();
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
case 'controls':
|
|
704
|
+
{
|
|
705
|
+
this._renderControls();
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
case 'direction':
|
|
709
|
+
{
|
|
710
|
+
if (Number(value) === -1) {
|
|
711
|
+
this.setDirection(-1);
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
this.setDirection(1);
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
717
|
+
case 'hover':
|
|
718
|
+
{
|
|
719
|
+
if (value === '' || Boolean(value)) {
|
|
720
|
+
this._container.addEventListener('mouseenter', this._mouseEnter);
|
|
721
|
+
this._container.addEventListener('mouseleave', this._mouseLeave);
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
this._container.removeEventListener('mouseenter', this._mouseEnter);
|
|
725
|
+
this._container.removeEventListener('mouseleave', this._mouseLeave);
|
|
726
|
+
break;
|
|
727
|
+
}
|
|
728
|
+
case 'loop':
|
|
729
|
+
{
|
|
730
|
+
const toggleLoop = this.shadow.querySelector('.toggleLoop');
|
|
731
|
+
if (toggleLoop instanceof HTMLButtonElement) {
|
|
732
|
+
toggleLoop.dataset.active = value;
|
|
733
|
+
}
|
|
734
|
+
this.setLoop(value === '' || Boolean(value));
|
|
735
|
+
break;
|
|
736
|
+
}
|
|
737
|
+
case 'mode':
|
|
738
|
+
{
|
|
739
|
+
const toggleBoomerang = this.shadow.querySelector('.toggleBoomerang');
|
|
740
|
+
if (toggleBoomerang instanceof HTMLButtonElement) {
|
|
741
|
+
toggleBoomerang.dataset.active = (value === PlayMode.Bounce).toString();
|
|
742
|
+
}
|
|
743
|
+
this._isBounce = value === PlayMode.Bounce;
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
case 'playOnClick':
|
|
747
|
+
{
|
|
748
|
+
if (value === '' || Boolean(value)) {
|
|
749
|
+
this._lottieInstance.autoplay = false;
|
|
750
|
+
this._container.addEventListener('click', this._handleClick);
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
this._container.removeEventListener('click', this._handleClick);
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
case 'playOnVisible':
|
|
757
|
+
{
|
|
758
|
+
if (value === '' || Boolean(value)) {
|
|
759
|
+
this._lottieInstance.autoplay = false;
|
|
760
|
+
}
|
|
761
|
+
break;
|
|
762
|
+
}
|
|
763
|
+
case 'speed':
|
|
764
|
+
{
|
|
765
|
+
const val = Number(value);
|
|
766
|
+
if (val && !isNaN(val)) {
|
|
767
|
+
this.setSpeed(val);
|
|
768
|
+
}
|
|
769
|
+
break;
|
|
770
|
+
}
|
|
771
|
+
case 'src':
|
|
772
|
+
{
|
|
773
|
+
await this.load(value);
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
case 'subframe':
|
|
777
|
+
{
|
|
778
|
+
this.setSubframe(value === '' || Boolean(value));
|
|
779
|
+
break;
|
|
780
|
+
}
|
|
678
781
|
}
|
|
679
782
|
}
|
|
680
783
|
/**
|
|
@@ -688,14 +791,14 @@ const notImplemented = 'Method is not implemented';
|
|
|
688
791
|
throw new Error('Missing Shadow element');
|
|
689
792
|
}
|
|
690
793
|
this._container = this.shadow.querySelector('.animation');
|
|
794
|
+
// Setup lottie player
|
|
795
|
+
await this.load(this.src);
|
|
691
796
|
// Add listener for Visibility API's change event.
|
|
692
797
|
if (typeof document.hidden !== 'undefined') {
|
|
693
798
|
document.addEventListener('visibilitychange', this._onVisibilityChange);
|
|
694
799
|
}
|
|
695
800
|
// Add intersection observer for detecting component being out-of-view.
|
|
696
801
|
this._addIntersectionObserver();
|
|
697
|
-
// Setup lottie player
|
|
698
|
-
await this.load(this.src);
|
|
699
802
|
this.dispatchEvent(new CustomEvent(PlayerEvents.Rendered));
|
|
700
803
|
})();
|
|
701
804
|
} catch (error) {
|
|
@@ -769,9 +872,10 @@ const notImplemented = 'Method is not implemented';
|
|
|
769
872
|
if (this._multiAnimationSettings.length > 0 && this._multiAnimationSettings[this._currentAnimation]?.mode) {
|
|
770
873
|
this._isBounce = this._multiAnimationSettings[this._currentAnimation]?.mode === PlayMode.Bounce;
|
|
771
874
|
}
|
|
875
|
+
// Relevant for dotLotties with multiple animations
|
|
772
876
|
const firstAnimation = manifest?.animations[0];
|
|
773
877
|
if (firstAnimation) {
|
|
774
|
-
firstAnimation.autoplay = this.autoplay;
|
|
878
|
+
firstAnimation.autoplay = !this.animateOnScroll && !this.playOnVisible && this.autoplay;
|
|
775
879
|
firstAnimation.loop = this.loop;
|
|
776
880
|
}
|
|
777
881
|
this._isDotLottie = isDotLottie;
|
|
@@ -779,7 +883,7 @@ const notImplemented = 'Method is not implemented';
|
|
|
779
883
|
this._manifest = manifest ?? {
|
|
780
884
|
animations: [
|
|
781
885
|
{
|
|
782
|
-
autoplay: !this.animateOnScroll && this.autoplay,
|
|
886
|
+
autoplay: !this.animateOnScroll && !this.playOnVisible && this.autoplay,
|
|
783
887
|
direction: this.direction,
|
|
784
888
|
id: createElementID(),
|
|
785
889
|
loop: this.loop,
|
|
@@ -791,7 +895,8 @@ const notImplemented = 'Method is not implemented';
|
|
|
791
895
|
// Clear previous animation, if any
|
|
792
896
|
this._lottieInstance?.destroy();
|
|
793
897
|
this.playerState = PlayerState.Stopped;
|
|
794
|
-
if (!this.animateOnScroll &&
|
|
898
|
+
if (!this.animateOnScroll && // !this.playOnVisible &&
|
|
899
|
+
(this.autoplay || this._multiAnimationSettings[this._currentAnimation]?.autoplay || this.playOnVisible)) {
|
|
795
900
|
this.playerState = PlayerState.Playing;
|
|
796
901
|
}
|
|
797
902
|
// Initialize lottie player and load animation
|
|
@@ -806,20 +911,18 @@ const notImplemented = 'Method is not implemented';
|
|
|
806
911
|
this._lottieInstance.setDirection(direction);
|
|
807
912
|
this._lottieInstance.setSubframe(Boolean(this.subframe));
|
|
808
913
|
// Start playing if autoplay is enabled
|
|
809
|
-
if (this.autoplay || this.animateOnScroll) {
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
}
|
|
819
|
-
this._addIntersectionObserver();
|
|
914
|
+
if ((this.autoplay || this.animateOnScroll || this.playOnVisible) && this.direction === -1) {
|
|
915
|
+
this.seek('99%');
|
|
916
|
+
// if (!('IntersectionObserver' in window)) {
|
|
917
|
+
// if (!this.animateOnScroll) {
|
|
918
|
+
// this.play()
|
|
919
|
+
// }
|
|
920
|
+
// this._playerState.visible = true
|
|
921
|
+
// }
|
|
922
|
+
// this._addIntersectionObserver()
|
|
820
923
|
}
|
|
821
924
|
this._renderControls();
|
|
822
|
-
if (this.autoplay) {
|
|
925
|
+
if (this.autoplay || this.playOnVisible) {
|
|
823
926
|
const togglePlay = this.shadow?.querySelector('.togglePlay');
|
|
824
927
|
if (togglePlay) {
|
|
825
928
|
togglePlay.innerHTML = pauseIcon;
|
|
@@ -848,11 +951,15 @@ const notImplemented = 'Method is not implemented';
|
|
|
848
951
|
return;
|
|
849
952
|
}
|
|
850
953
|
this._playerState.prev = this.playerState;
|
|
954
|
+
let hasError = false;
|
|
851
955
|
try {
|
|
852
956
|
this._lottieInstance.pause();
|
|
853
957
|
this.dispatchEvent(new CustomEvent(PlayerEvents.Pause));
|
|
958
|
+
} catch (error) {
|
|
959
|
+
hasError = true;
|
|
960
|
+
console.error(error);
|
|
854
961
|
} finally{
|
|
855
|
-
this.playerState = PlayerState.Paused;
|
|
962
|
+
this.playerState = hasError ? PlayerState.Error : PlayerState.Paused;
|
|
856
963
|
}
|
|
857
964
|
}
|
|
858
965
|
/**
|
|
@@ -862,11 +969,15 @@ const notImplemented = 'Method is not implemented';
|
|
|
862
969
|
return;
|
|
863
970
|
}
|
|
864
971
|
this._playerState.prev = this.playerState;
|
|
972
|
+
let hasError = false;
|
|
865
973
|
try {
|
|
866
974
|
this._lottieInstance.play();
|
|
867
975
|
this.dispatchEvent(new CustomEvent(PlayerEvents.Play));
|
|
976
|
+
} catch (error) {
|
|
977
|
+
hasError = true;
|
|
978
|
+
console.error(error);
|
|
868
979
|
} finally{
|
|
869
|
-
this.playerState = PlayerState.Playing;
|
|
980
|
+
this.playerState = hasError ? PlayerState.Error : PlayerState.Playing;
|
|
870
981
|
}
|
|
871
982
|
}
|
|
872
983
|
/**
|
|
@@ -1124,6 +1235,14 @@ const notImplemented = 'Method is not implemented';
|
|
|
1124
1235
|
}, 200);
|
|
1125
1236
|
}
|
|
1126
1237
|
/**
|
|
1238
|
+
* Handle click.
|
|
1239
|
+
*/ _handleClick() {
|
|
1240
|
+
if (!this.playOnClick) {
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
this.togglePlay();
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1127
1246
|
* Handles click and drag actions on the progress track.
|
|
1128
1247
|
*/ _handleSeekChange({ target }) {
|
|
1129
1248
|
if (!(target instanceof HTMLInputElement) || !this._lottieInstance || isNaN(Number(target.value))) {
|
|
@@ -1151,7 +1270,16 @@ const notImplemented = 'Method is not implemented';
|
|
|
1151
1270
|
/**
|
|
1152
1271
|
* Add IntersectionObserver.
|
|
1153
1272
|
*/ _addIntersectionObserver() {
|
|
1154
|
-
if (!this._container || this._intersectionObserver
|
|
1273
|
+
if (!this._container || this._intersectionObserver) {
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
if (!('IntersectionObserver' in window)) {
|
|
1277
|
+
this._intersectionObserverFallback();
|
|
1278
|
+
removeEventListener('scroll', this._intersectionObserverFallback, true);
|
|
1279
|
+
addEventListener('scroll', this._intersectionObserverFallback, {
|
|
1280
|
+
capture: true,
|
|
1281
|
+
passive: true
|
|
1282
|
+
});
|
|
1155
1283
|
return;
|
|
1156
1284
|
}
|
|
1157
1285
|
this._intersectionObserver = new IntersectionObserver((entries)=>{
|
|
@@ -1164,9 +1292,19 @@ const notImplemented = 'Method is not implemented';
|
|
|
1164
1292
|
this._playerState.visible = false;
|
|
1165
1293
|
continue;
|
|
1166
1294
|
}
|
|
1167
|
-
if (!this.animateOnScroll && this.playerState === PlayerState.Frozen) {
|
|
1295
|
+
if (!this.animateOnScroll && !this.playOnVisible && this.playerState === PlayerState.Frozen) {
|
|
1168
1296
|
this.play();
|
|
1169
1297
|
}
|
|
1298
|
+
if (this.playOnVisible) {
|
|
1299
|
+
if (this.playerState === PlayerState.Completed && !this.once) {
|
|
1300
|
+
this.playerState = PlayerState.Playing;
|
|
1301
|
+
this._lottieInstance?.goToAndPlay(this.direction === 1 ? 0 : this._lottieInstance.totalFrames);
|
|
1302
|
+
} else {
|
|
1303
|
+
setTimeout(()=>{
|
|
1304
|
+
this.play();
|
|
1305
|
+
}, this.delay);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1170
1308
|
/**
|
|
1171
1309
|
* If the player is a ways down the page, we need to account for this by
|
|
1172
1310
|
* setting _playerState.scrollY to the current scroll position. However, we
|
|
@@ -1314,6 +1452,20 @@ const notImplemented = 'Method is not implemented';
|
|
|
1314
1452
|
this.play();
|
|
1315
1453
|
}
|
|
1316
1454
|
}
|
|
1455
|
+
_intersectionObserverFallback() {
|
|
1456
|
+
if (!this._container) {
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
const { bottom, left, right, top } = this._container.getBoundingClientRect();
|
|
1460
|
+
this._playerState.visible = top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth;
|
|
1461
|
+
if (this.autoplay || this.playOnVisible || this.playerState === PlayerState.Playing || this.playerState === PlayerState.Frozen) {
|
|
1462
|
+
if (this._playerState.visible) {
|
|
1463
|
+
this.play();
|
|
1464
|
+
} else {
|
|
1465
|
+
this._freeze();
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1317
1469
|
_loopComplete() {
|
|
1318
1470
|
if (!this._lottieInstance) {
|
|
1319
1471
|
return;
|
|
@@ -1353,15 +1505,51 @@ const notImplemented = 'Method is not implemented';
|
|
|
1353
1505
|
/**
|
|
1354
1506
|
* Handle MouseEnter.
|
|
1355
1507
|
*/ _mouseEnter() {
|
|
1356
|
-
if (this.hover
|
|
1508
|
+
if (!this.hover || !this._lottieInstance || isTouch()) {
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1511
|
+
if (this.mouseout === 'reverse') {
|
|
1512
|
+
this._lottieInstance.setDirection(1);
|
|
1513
|
+
}
|
|
1514
|
+
if (this.playerState === PlayerState.Completed) {
|
|
1515
|
+
this._lottieInstance.goToAndPlay(0, true);
|
|
1516
|
+
this.playerState = PlayerState.Playing;
|
|
1517
|
+
return;
|
|
1518
|
+
}
|
|
1519
|
+
if (this.playerState !== PlayerState.Playing) {
|
|
1357
1520
|
this.play();
|
|
1358
1521
|
}
|
|
1359
1522
|
}
|
|
1360
1523
|
/**
|
|
1361
1524
|
* Handle MouseLeave.
|
|
1362
1525
|
*/ _mouseLeave() {
|
|
1363
|
-
if (this.hover
|
|
1364
|
-
|
|
1526
|
+
if (!this.hover || !this._lottieInstance || isTouch()) {
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
switch(this.mouseout){
|
|
1530
|
+
case 'void':
|
|
1531
|
+
{
|
|
1532
|
+
break;
|
|
1533
|
+
}
|
|
1534
|
+
case 'pause':
|
|
1535
|
+
{
|
|
1536
|
+
this.pause();
|
|
1537
|
+
break;
|
|
1538
|
+
}
|
|
1539
|
+
case 'reverse':
|
|
1540
|
+
{
|
|
1541
|
+
// const { direction = 1 } =
|
|
1542
|
+
// this._multiAnimationSettings.length > 0 ?
|
|
1543
|
+
// this._multiAnimationSettings[this._currentAnimation + 1] ?? { direction: 1 } : this,
|
|
1544
|
+
// newDirection = direction * -1 as AnimationDirection
|
|
1545
|
+
this._lottieInstance.setDirection(-1);
|
|
1546
|
+
this.play();
|
|
1547
|
+
break;
|
|
1548
|
+
}
|
|
1549
|
+
default:
|
|
1550
|
+
{
|
|
1551
|
+
this.stop();
|
|
1552
|
+
}
|
|
1365
1553
|
}
|
|
1366
1554
|
}
|
|
1367
1555
|
/**
|
|
@@ -1433,9 +1621,14 @@ const notImplemented = 'Method is not implemented';
|
|
|
1433
1621
|
this._lottieInstance[method]('data_ready', this._dataReady);
|
|
1434
1622
|
this._lottieInstance[method]('data_failed', this._dataFailed);
|
|
1435
1623
|
}
|
|
1436
|
-
if (this._container
|
|
1437
|
-
|
|
1438
|
-
|
|
1624
|
+
if (this._container) {
|
|
1625
|
+
if (this.hover) {
|
|
1626
|
+
this._container[method]('mouseenter', this._mouseEnter);
|
|
1627
|
+
this._container[method]('mouseleave', this._mouseLeave);
|
|
1628
|
+
}
|
|
1629
|
+
if (this.playOnClick) {
|
|
1630
|
+
this._container[method]('click', this._handleClick);
|
|
1631
|
+
}
|
|
1439
1632
|
}
|
|
1440
1633
|
window[method]('focus', this._handleWindowBlur, {
|
|
1441
1634
|
capture: false,
|