@wix/interact 1.93.0 → 1.94.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/dist/cjs/__tests__/interact.spec.js +170 -0
- package/dist/cjs/__tests__/interact.spec.js.map +1 -1
- package/dist/cjs/__tests__/viewEnter.spec.js +23 -6
- package/dist/cjs/__tests__/viewEnter.spec.js.map +1 -1
- package/dist/cjs/core/add.js.map +1 -1
- package/dist/cjs/handlers/animationEnd.js +6 -1
- package/dist/cjs/handlers/animationEnd.js.map +1 -1
- package/dist/cjs/handlers/click.js +12 -2
- package/dist/cjs/handlers/click.js.map +1 -1
- package/dist/cjs/handlers/hover.js +13 -3
- package/dist/cjs/handlers/hover.js.map +1 -1
- package/dist/cjs/handlers/viewEnter.js +7 -2
- package/dist/cjs/handlers/viewEnter.js.map +1 -1
- package/dist/cjs/handlers/viewProgress.js +3 -1
- package/dist/cjs/handlers/viewProgress.js.map +1 -1
- package/dist/esm/__tests__/interact.spec.js +170 -0
- package/dist/esm/__tests__/interact.spec.js.map +1 -1
- package/dist/esm/__tests__/viewEnter.spec.js +23 -6
- package/dist/esm/__tests__/viewEnter.spec.js.map +1 -1
- package/dist/esm/core/add.js.map +1 -1
- package/dist/esm/handlers/animationEnd.js +6 -1
- package/dist/esm/handlers/animationEnd.js.map +1 -1
- package/dist/esm/handlers/click.js +12 -2
- package/dist/esm/handlers/click.js.map +1 -1
- package/dist/esm/handlers/hover.js +13 -3
- package/dist/esm/handlers/hover.js.map +1 -1
- package/dist/esm/handlers/viewEnter.js +7 -2
- package/dist/esm/handlers/viewEnter.js.map +1 -1
- package/dist/esm/handlers/viewProgress.js +3 -1
- package/dist/esm/handlers/viewProgress.js.map +1 -1
- package/dist/types/__tests__/viewEnter.spec.d.ts +7 -0
- package/package.json +3 -3
|
@@ -680,6 +680,176 @@ describe('interact', () => {
|
|
|
680
680
|
});
|
|
681
681
|
});
|
|
682
682
|
});
|
|
683
|
+
describe('null animation handling', () => {
|
|
684
|
+
it('should not add click handler when getAnimation returns null', () => {
|
|
685
|
+
_Interact.Interact.destroy();
|
|
686
|
+
const {
|
|
687
|
+
getWebAnimation
|
|
688
|
+
} = require('@wix/motion');
|
|
689
|
+
_Interact.Interact.create({
|
|
690
|
+
interactions: [{
|
|
691
|
+
trigger: 'click',
|
|
692
|
+
key: 'null-click-test',
|
|
693
|
+
effects: [{
|
|
694
|
+
effectId: 'null-test-effect'
|
|
695
|
+
}]
|
|
696
|
+
}],
|
|
697
|
+
effects: {
|
|
698
|
+
'null-test-effect': {
|
|
699
|
+
namedEffect: {
|
|
700
|
+
type: 'FadeIn'
|
|
701
|
+
},
|
|
702
|
+
duration: 500
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
getWebAnimation.mockReturnValueOnce(null);
|
|
707
|
+
element = document.createElement('interact-element');
|
|
708
|
+
const div = document.createElement('div');
|
|
709
|
+
element.append(div);
|
|
710
|
+
const addEventListenerSpy = jest.spyOn(div, 'addEventListener');
|
|
711
|
+
(0, _add.add)(element, 'null-click-test');
|
|
712
|
+
expect(addEventListenerSpy).not.toHaveBeenCalled();
|
|
713
|
+
});
|
|
714
|
+
it('should not add hover handler when getAnimation returns null', () => {
|
|
715
|
+
_Interact.Interact.destroy();
|
|
716
|
+
const {
|
|
717
|
+
getWebAnimation
|
|
718
|
+
} = require('@wix/motion');
|
|
719
|
+
_Interact.Interact.create({
|
|
720
|
+
interactions: [{
|
|
721
|
+
trigger: 'hover',
|
|
722
|
+
key: 'null-hover-test',
|
|
723
|
+
effects: [{
|
|
724
|
+
effectId: 'null-test-effect'
|
|
725
|
+
}]
|
|
726
|
+
}],
|
|
727
|
+
effects: {
|
|
728
|
+
'null-test-effect': {
|
|
729
|
+
namedEffect: {
|
|
730
|
+
type: 'FadeIn'
|
|
731
|
+
},
|
|
732
|
+
duration: 500
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
getWebAnimation.mockReturnValueOnce(null);
|
|
737
|
+
element = document.createElement('interact-element');
|
|
738
|
+
const div = document.createElement('div');
|
|
739
|
+
element.append(div);
|
|
740
|
+
const addEventListenerSpy = jest.spyOn(div, 'addEventListener');
|
|
741
|
+
(0, _add.add)(element, 'null-hover-test');
|
|
742
|
+
expect(addEventListenerSpy).not.toHaveBeenCalled();
|
|
743
|
+
});
|
|
744
|
+
it('should not add animationEnd handler when getAnimation returns null', () => {
|
|
745
|
+
_Interact.Interact.destroy();
|
|
746
|
+
const {
|
|
747
|
+
getWebAnimation
|
|
748
|
+
} = require('@wix/motion');
|
|
749
|
+
_Interact.Interact.create({
|
|
750
|
+
interactions: [{
|
|
751
|
+
trigger: 'animationEnd',
|
|
752
|
+
key: 'null-animationend-test',
|
|
753
|
+
params: {
|
|
754
|
+
effectId: 'trigger-effect'
|
|
755
|
+
},
|
|
756
|
+
effects: [{
|
|
757
|
+
effectId: 'null-test-effect'
|
|
758
|
+
}]
|
|
759
|
+
}],
|
|
760
|
+
effects: {
|
|
761
|
+
'null-test-effect': {
|
|
762
|
+
namedEffect: {
|
|
763
|
+
type: 'FadeIn'
|
|
764
|
+
},
|
|
765
|
+
duration: 500
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
getWebAnimation.mockReturnValueOnce(null);
|
|
770
|
+
element = document.createElement('interact-element');
|
|
771
|
+
const div = document.createElement('div');
|
|
772
|
+
element.append(div);
|
|
773
|
+
const addEventListenerSpy = jest.spyOn(div, 'addEventListener');
|
|
774
|
+
(0, _add.add)(element, 'null-animationend-test');
|
|
775
|
+
expect(addEventListenerSpy).not.toHaveBeenCalled();
|
|
776
|
+
});
|
|
777
|
+
it('should not add viewProgress handler when getWebAnimation returns null (ViewTimeline)', () => {
|
|
778
|
+
_Interact.Interact.destroy();
|
|
779
|
+
const {
|
|
780
|
+
getWebAnimation
|
|
781
|
+
} = require('@wix/motion');
|
|
782
|
+
_Interact.Interact.create({
|
|
783
|
+
interactions: [{
|
|
784
|
+
trigger: 'viewProgress',
|
|
785
|
+
key: 'null-viewprogress-test',
|
|
786
|
+
effects: [{
|
|
787
|
+
effectId: 'null-scroll-effect'
|
|
788
|
+
}]
|
|
789
|
+
}],
|
|
790
|
+
effects: {
|
|
791
|
+
'null-scroll-effect': {
|
|
792
|
+
namedEffect: {
|
|
793
|
+
type: 'FadeScroll',
|
|
794
|
+
range: 'in',
|
|
795
|
+
opacity: 0
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
getWebAnimation.mockReturnValueOnce(null);
|
|
801
|
+
element = document.createElement('interact-element');
|
|
802
|
+
const div = document.createElement('div');
|
|
803
|
+
element.append(div);
|
|
804
|
+
(0, _add.add)(element, 'null-viewprogress-test');
|
|
805
|
+
|
|
806
|
+
// getWebAnimation should have been called
|
|
807
|
+
expect(getWebAnimation).toHaveBeenCalled();
|
|
808
|
+
});
|
|
809
|
+
it('should not add viewProgress handler when getScrubScene returns null (polyfill)', () => {
|
|
810
|
+
// Remove ViewTimeline support to use polyfill path
|
|
811
|
+
delete window.ViewTimeline;
|
|
812
|
+
_Interact.Interact.destroy();
|
|
813
|
+
const {
|
|
814
|
+
getScrubScene
|
|
815
|
+
} = require('@wix/motion');
|
|
816
|
+
_Interact.Interact.create({
|
|
817
|
+
interactions: [{
|
|
818
|
+
trigger: 'viewProgress',
|
|
819
|
+
key: 'null-viewprogress-polyfill-test',
|
|
820
|
+
effects: [{
|
|
821
|
+
effectId: 'null-scroll-effect'
|
|
822
|
+
}]
|
|
823
|
+
}],
|
|
824
|
+
effects: {
|
|
825
|
+
'null-scroll-effect': {
|
|
826
|
+
namedEffect: {
|
|
827
|
+
type: 'FadeScroll',
|
|
828
|
+
range: 'in',
|
|
829
|
+
opacity: 0
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
getScrubScene.mockReturnValueOnce(null);
|
|
835
|
+
element = document.createElement('interact-element');
|
|
836
|
+
const div = document.createElement('div');
|
|
837
|
+
element.append(div);
|
|
838
|
+
(0, _add.add)(element, 'null-viewprogress-polyfill-test');
|
|
839
|
+
|
|
840
|
+
// getScrubScene should have been called
|
|
841
|
+
expect(getScrubScene).toHaveBeenCalled();
|
|
842
|
+
|
|
843
|
+
// Restore ViewTimeline
|
|
844
|
+
window.ViewTimeline = class ViewTimeline {
|
|
845
|
+
constructor(options) {
|
|
846
|
+
return {
|
|
847
|
+
...options
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
});
|
|
852
|
+
});
|
|
683
853
|
describe('pointerMove', () => {
|
|
684
854
|
it('should add handler for pointerMove trigger', () => {
|
|
685
855
|
const {
|