@wix/interact 1.79.0 → 1.81.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/WixInteractElement.js +9 -0
- package/dist/cjs/WixInteractElement.js.map +1 -1
- package/dist/cjs/__tests__/interact.spec.js +45 -19
- package/dist/cjs/__tests__/interact.spec.js.map +1 -1
- package/dist/cjs/core/Interact.js +41 -10
- package/dist/cjs/core/Interact.js.map +1 -1
- package/dist/cjs/core/add.js +5 -1
- package/dist/cjs/core/add.js.map +1 -1
- package/dist/cjs/core/remove.js +2 -3
- package/dist/cjs/core/remove.js.map +1 -1
- package/dist/esm/WixInteractElement.js +9 -0
- package/dist/esm/WixInteractElement.js.map +1 -1
- package/dist/esm/__tests__/interact.spec.js +45 -19
- package/dist/esm/__tests__/interact.spec.js.map +1 -1
- package/dist/esm/core/Interact.js +41 -10
- package/dist/esm/core/Interact.js.map +1 -1
- package/dist/esm/core/add.js +5 -1
- package/dist/esm/core/add.js.map +1 -1
- package/dist/esm/core/remove.js +2 -3
- package/dist/esm/core/remove.js.map +1 -1
- package/dist/types/WixInteractElement.d.ts +1 -0
- package/dist/types/core/Interact.d.ts +4 -0
- package/package.json +6 -6
|
@@ -112,6 +112,15 @@ function getWixInteractElement() {
|
|
|
112
112
|
this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR] = Array.from(currentEffects).join(' ');
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
+
getActiveEffects() {
|
|
116
|
+
if (this._internals) {
|
|
117
|
+
const effects = Array.from(this._internals.states);
|
|
118
|
+
return isLegacyStateSyntax ? effects.map(effect => effect.replace(/^--/g, '')) : effects;
|
|
119
|
+
}
|
|
120
|
+
const raw = this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR] || '';
|
|
121
|
+
const trimmed = raw.trim();
|
|
122
|
+
return trimmed ? trimmed.split(/\s+/) : [];
|
|
123
|
+
}
|
|
115
124
|
watchChildList(listContainer) {
|
|
116
125
|
const list = this.querySelector(listContainer);
|
|
117
126
|
if (list) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_add","require","_remove","WIX_INTERACT_EFFECT_DATA_ATTR","exports","getWixInteractElement","checkedForLegacyStateSyntax","isLegacyStateSyntax","WixInteractElement","HTMLElement","constructor","_defineProperty2","default","connected","sheet","_observers","WeakMap","attachInternals","_internals","states","add","delete","e","connectedCallback","connect","disconnectedCallback","disconnect","key","dataset","wixPath","remove","index","document","adoptedStyleSheets","indexOf","splice","console","warn","renderStyle","cssRules","CSSStyleSheet","replace","join","push","position","length","cssRule","insertRule","error","toggleEffect","effectId","method","has","clear","_this$dataset$WIX_INT","currentEffects","Set","split","Array","from","watchChildList","listContainer","list","querySelector","observer","get","MutationObserver","_childListChangeHandler","bind","set","observe","childList","entries","removedElements","addedElements","forEach","entry","removedNodes","el","addedNodes","removeListItems","addListItems"],"sources":["../../src/WixInteractElement.ts"],"sourcesContent":["import type { StateParams } from './types';\nimport { add, addListItems } from './core/add';\nimport { remove, removeListItems } from './core/remove';\n\nexport const WIX_INTERACT_EFFECT_DATA_ATTR = 'wixInteractEffect';\n\nexport function getWixInteractElement() {\n let checkedForLegacyStateSyntax = false;\n let isLegacyStateSyntax = false;\n\n return class WixInteractElement extends HTMLElement {\n _internals: (ElementInternals & { states: Set<string> }) | null;\n connected: boolean;\n sheet: CSSStyleSheet | null;\n _observers: WeakMap<HTMLElement, MutationObserver>;\n\n constructor() {\n super();\n\n this.connected = false;\n this.sheet = null;\n this._observers = new WeakMap();\n\n if (this.attachInternals) {\n this._internals = this.attachInternals() as ElementInternals & {\n states: Set<string>;\n };\n\n if (!checkedForLegacyStateSyntax) {\n checkedForLegacyStateSyntax = true;\n\n try {\n this._internals.states.add('test');\n this._internals.states.delete('test');\n } catch (e) {\n isLegacyStateSyntax = true;\n }\n }\n } else {\n checkedForLegacyStateSyntax = true; // custom states not supported - skip syntax check\n this._internals = null;\n }\n }\n connectedCallback() {\n this.connect();\n }\n\n disconnectedCallback() {\n this.disconnect();\n }\n\n disconnect() {\n const key = this.dataset.wixPath;\n\n if (key) {\n remove(key);\n }\n\n if (this.sheet) {\n const index = document.adoptedStyleSheets.indexOf(this.sheet);\n document.adoptedStyleSheets.splice(index, 1);\n }\n\n this._observers = new WeakMap();\n\n this.connected = false;\n }\n\n connect(key?: string) {\n if (this.connected) {\n return;\n }\n\n key = key || this.dataset.wixPath;\n\n if (!key) {\n console.warn('WixInteractElement: No key provided');\n return;\n }\n\n this.connected = add(this, key);\n }\n\n renderStyle(cssRules: string[]) {\n if (!this.sheet) {\n this.sheet = new CSSStyleSheet();\n void this.sheet.replace(cssRules.join('\\n'));\n\n document.adoptedStyleSheets.push(this.sheet);\n } else {\n let position = this.sheet.cssRules.length;\n\n for (const cssRule of cssRules) {\n try {\n this.sheet.insertRule(cssRule, position);\n position++;\n } catch (e) {\n console.error(e);\n }\n }\n }\n }\n\n toggleEffect(effectId: string, method: StateParams['method']) {\n if (isLegacyStateSyntax) {\n effectId = `--${effectId}`;\n }\n\n if (this._internals) {\n if (method === 'toggle') {\n this._internals.states.has(effectId)\n ? this._internals.states.delete(effectId)\n : this._internals.states.add(effectId);\n } else if (method === 'add') {\n this._internals.states.add(effectId);\n } else if (method === 'remove') {\n this._internals.states.delete(effectId);\n } else if (method === 'clear') {\n this._internals.states.clear();\n }\n } else {\n const currentEffects = new Set(\n this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR]?.split(' ') || [],\n );\n\n if (method === 'toggle') {\n currentEffects.has(effectId)\n ? currentEffects.delete(effectId)\n : currentEffects.add(effectId);\n } else if (method === 'add') {\n currentEffects.add(effectId);\n } else if (method === 'remove') {\n currentEffects.delete(effectId);\n } else if (method === 'clear') {\n currentEffects.clear();\n }\n\n this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR] =\n Array.from(currentEffects).join(' ');\n }\n }\n\n watchChildList(listContainer: string): void {\n const list = this.querySelector(listContainer);\n\n if (list) {\n // TODO: we can probably improve this and use less observers, this impl. uses one per container element\n let observer = this._observers.get(list as HTMLElement);\n\n if (!observer) {\n observer = new MutationObserver(\n this._childListChangeHandler.bind(this, listContainer),\n );\n\n this._observers.set(list as HTMLElement, observer);\n\n observer.observe(list as HTMLElement, { childList: true });\n }\n }\n }\n\n _childListChangeHandler(listContainer: string, entries: MutationRecord[]) {\n const key = this.dataset.wixPath;\n const removedElements: HTMLElement[] = [];\n const addedElements: HTMLElement[] = [];\n\n entries.forEach((entry) => {\n entry.removedNodes.forEach((el) => {\n if (el instanceof HTMLElement) {\n removedElements.push(el);\n }\n });\n\n entry.addedNodes.forEach((el) => {\n if (el instanceof HTMLElement) {\n addedElements.push(el);\n }\n });\n });\n\n removeListItems(removedElements);\n key && addListItems(this, key, listContainer, addedElements);\n }\n };\n}\n"],"mappings":";;;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEO,MAAME,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,GAAG,mBAAmB;AAEzD,SAASE,qBAAqBA,CAAA,EAAG;EACtC,IAAIC,2BAA2B,GAAG,KAAK;EACvC,IAAIC,mBAAmB,GAAG,KAAK;EAE/B,OAAO,MAAMC,kBAAkB,SAASC,WAAW,CAAC;IAMlDC,WAAWA,CAAA,EAAG;MACZ,KAAK,CAAC,CAAC;MAAC,IAAAC,gBAAA,CAAAC,OAAA;MAAA,IAAAD,gBAAA,CAAAC,OAAA;MAAA,IAAAD,gBAAA,CAAAC,OAAA;MAAA,IAAAD,gBAAA,CAAAC,OAAA;MAER,IAAI,CAACC,SAAS,GAAG,KAAK;MACtB,IAAI,CAACC,KAAK,GAAG,IAAI;MACjB,IAAI,CAACC,UAAU,GAAG,IAAIC,OAAO,CAAC,CAAC;MAE/B,IAAI,IAAI,CAACC,eAAe,EAAE;QACxB,IAAI,CAACC,UAAU,GAAG,IAAI,CAACD,eAAe,CAAC,CAEtC;QAED,IAAI,CAACX,2BAA2B,E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,CAACH,IAAmB,CAAC;QAEvD,IAAI,CAACE,QAAQ,EAAE;UACbA,QAAQ,GAAG,IAAIE,gBAAgB,CAC7B,IAAI,CAACC,uBAAuB,CAACC,IAAI,CAAC,IAAI,EAAEP,aAAa,CACvD,CAAC;UAED,IAAI,CAAC9C,UAAU,CAACsD,GAAG,CAACP,IAAI,EAAiBE,QAAQ,CAAC;UAElDA,QAAQ,CAACM,OAAO,CAACR,IAAI,EAAiB;YAAES,SAAS,EAAE;UAAK,CAAC,CAAC;QAC5D;MACF;IACF;IAEAJ,uBAAuBA,CAACN,aAAqB,EAAEW,OAAyB,EAAE;MACxE,MAAM7C,GAAG,GAAG,IAAI,CAACC,OAAO,CAACC,OAAO;MAChC,MAAM4C,eAA8B,GAAG,EAAE;MACzC,MAAMC,aAA4B,GAAG,EAAE;MAEvCF,OAAO,CAACG,OAAO,CAAEC,KAAK,IAAK;QACzBA,KAAK,CAACC,YAAY,CAACF,OAAO,CAAEG,EAAE,IAAK;UACjC,IAAIA,EAAE,YAAYrE,WAAW,EAAE;YAC7BgE,eAAe,CAAC9B,IAAI,CAACmC,EAAE,CAAC;UAC1B;QACF,CAAC,CAAC;QAEFF,KAAK,CAACG,UAAU,CAACJ,OAAO,CAAEG,EAAE,IAAK;UAC/B,IAAIA,EAAE,YAAYrE,WAAW,EAAE;YAC7BiE,aAAa,CAAC/B,IAAI,CAACmC,EAAE,CAAC;UACxB;QACF,CAAC,CAAC;MACJ,CAAC,CAAC;MAEF,IAAAE,uBAAe,EAACP,eAAe,CAAC;MAChC9C,GAAG,IAAI,IAAAsD,iBAAY,EAAC,IAAI,EAAEtD,GAAG,EAAEkC,aAAa,EAAEa,aAAa,CAAC;IAC9D;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_add","require","_remove","WIX_INTERACT_EFFECT_DATA_ATTR","exports","getWixInteractElement","checkedForLegacyStateSyntax","isLegacyStateSyntax","WixInteractElement","HTMLElement","constructor","_defineProperty2","default","connected","sheet","_observers","WeakMap","attachInternals","_internals","states","add","delete","e","connectedCallback","connect","disconnectedCallback","disconnect","key","dataset","wixPath","remove","index","document","adoptedStyleSheets","indexOf","splice","console","warn","renderStyle","cssRules","CSSStyleSheet","replace","join","push","position","length","cssRule","insertRule","error","toggleEffect","effectId","method","has","clear","_this$dataset$WIX_INT","currentEffects","Set","split","Array","from","getActiveEffects","effects","map","effect","raw","trimmed","trim","watchChildList","listContainer","list","querySelector","observer","get","MutationObserver","_childListChangeHandler","bind","set","observe","childList","entries","removedElements","addedElements","forEach","entry","removedNodes","el","addedNodes","removeListItems","addListItems"],"sources":["../../src/WixInteractElement.ts"],"sourcesContent":["import type { StateParams } from './types';\nimport { add, addListItems } from './core/add';\nimport { remove, removeListItems } from './core/remove';\n\nexport const WIX_INTERACT_EFFECT_DATA_ATTR = 'wixInteractEffect';\n\nexport function getWixInteractElement() {\n let checkedForLegacyStateSyntax = false;\n let isLegacyStateSyntax = false;\n\n return class WixInteractElement extends HTMLElement {\n _internals: (ElementInternals & { states: Set<string> }) | null;\n connected: boolean;\n sheet: CSSStyleSheet | null;\n _observers: WeakMap<HTMLElement, MutationObserver>;\n\n constructor() {\n super();\n\n this.connected = false;\n this.sheet = null;\n this._observers = new WeakMap();\n\n if (this.attachInternals) {\n this._internals = this.attachInternals() as ElementInternals & {\n states: Set<string>;\n };\n\n if (!checkedForLegacyStateSyntax) {\n checkedForLegacyStateSyntax = true;\n\n try {\n this._internals.states.add('test');\n this._internals.states.delete('test');\n } catch (e) {\n isLegacyStateSyntax = true;\n }\n }\n } else {\n checkedForLegacyStateSyntax = true; // custom states not supported - skip syntax check\n this._internals = null;\n }\n }\n connectedCallback() {\n this.connect();\n }\n\n disconnectedCallback() {\n this.disconnect();\n }\n\n disconnect() {\n const key = this.dataset.wixPath;\n\n if (key) {\n remove(key);\n }\n\n if (this.sheet) {\n const index = document.adoptedStyleSheets.indexOf(this.sheet);\n document.adoptedStyleSheets.splice(index, 1);\n }\n\n this._observers = new WeakMap();\n\n this.connected = false;\n }\n\n connect(key?: string) {\n if (this.connected) {\n return;\n }\n\n key = key || this.dataset.wixPath;\n\n if (!key) {\n console.warn('WixInteractElement: No key provided');\n return;\n }\n\n this.connected = add(this, key);\n }\n\n renderStyle(cssRules: string[]) {\n if (!this.sheet) {\n this.sheet = new CSSStyleSheet();\n void this.sheet.replace(cssRules.join('\\n'));\n\n document.adoptedStyleSheets.push(this.sheet);\n } else {\n let position = this.sheet.cssRules.length;\n\n for (const cssRule of cssRules) {\n try {\n this.sheet.insertRule(cssRule, position);\n position++;\n } catch (e) {\n console.error(e);\n }\n }\n }\n }\n\n toggleEffect(effectId: string, method: StateParams['method']) {\n if (isLegacyStateSyntax) {\n effectId = `--${effectId}`;\n }\n\n if (this._internals) {\n if (method === 'toggle') {\n this._internals.states.has(effectId)\n ? this._internals.states.delete(effectId)\n : this._internals.states.add(effectId);\n } else if (method === 'add') {\n this._internals.states.add(effectId);\n } else if (method === 'remove') {\n this._internals.states.delete(effectId);\n } else if (method === 'clear') {\n this._internals.states.clear();\n }\n } else {\n const currentEffects = new Set(\n this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR]?.split(' ') || [],\n );\n\n if (method === 'toggle') {\n currentEffects.has(effectId)\n ? currentEffects.delete(effectId)\n : currentEffects.add(effectId);\n } else if (method === 'add') {\n currentEffects.add(effectId);\n } else if (method === 'remove') {\n currentEffects.delete(effectId);\n } else if (method === 'clear') {\n currentEffects.clear();\n }\n\n this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR] =\n Array.from(currentEffects).join(' ');\n }\n }\n\n getActiveEffects(): string[] {\n if (this._internals) {\n const effects = Array.from(this._internals.states);\n return isLegacyStateSyntax\n ? effects.map((effect) => effect.replace(/^--/g, ''))\n : effects;\n }\n\n const raw = this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR] || '';\n const trimmed = raw.trim();\n return trimmed ? trimmed.split(/\\s+/) : [];\n }\n\n watchChildList(listContainer: string): void {\n const list = this.querySelector(listContainer);\n\n if (list) {\n // TODO: we can probably improve this and use less observers, this impl. uses one per container element\n let observer = this._observers.get(list as HTMLElement);\n\n if (!observer) {\n observer = new MutationObserver(\n this._childListChangeHandler.bind(this, listContainer),\n );\n\n this._observers.set(list as HTMLElement, observer);\n\n observer.observe(list as HTMLElement, { childList: true });\n }\n }\n }\n\n _childListChangeHandler(listContainer: string, entries: MutationRecord[]) {\n const key = this.dataset.wixPath;\n const removedElements: HTMLElement[] = [];\n const addedElements: HTMLElement[] = [];\n\n entries.forEach((entry) => {\n entry.removedNodes.forEach((el) => {\n if (el instanceof HTMLElement) {\n removedElements.push(el);\n }\n });\n\n entry.addedNodes.forEach((el) => {\n if (el instanceof HTMLElement) {\n addedElements.push(el);\n }\n });\n });\n\n removeListItems(removedElements);\n key && addListItems(this, key, listContainer, addedElements);\n }\n };\n}\n"],"mappings":";;;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEO,MAAME,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,GAAG,mBAAmB;AAEzD,SAASE,qBAAqBA,CAAA,EAAG;EACtC,IAAIC,2BAA2B,GAAG,KAAK;EACvC,IAAIC,mBAAmB,GAAG,KAAK;EAE/B,OAAO,MAAMC,kBAAkB,SAASC,WAAW,CAAC;IAMlDC,WAAWA,CAAA,EAAG;MACZ,KAAK,CAAC,CAAC;MAAC,IAAAC,gBAAA,CAAAC,OAAA;MAAA,IAAAD,gBAAA,CAAAC,OAAA;MAAA,IAAAD,gBAAA,CAAAC,OAAA;MAAA,IAAAD,gBAAA,CAAAC,OAAA;MAER,IAAI,CAACC,SAAS,GAAG,KAAK;MACtB,IAAI,CAACC,KAAK,GAAG,IAAI;MACjB,IAAI,CAACC,UAAU,GAAG,IAAIC,OAAO,CAAC,CAAC;MAE/B,IAAI,IAAI,CAACC,eAAe,EAAE;QACxB,IAAI,CAACC,UAAU,GAAG,IAAI,CAACD,eAAe,CAAC,CAE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,CAAC0C,EAAE,CAAC;UAC1B;QACF,CAAC,CAAC;QAEFF,KAAK,CAACG,UAAU,CAACJ,OAAO,CAAEG,EAAE,IAAK;UAC/B,IAAIA,EAAE,YAAY5E,WAAW,EAAE;YAC7BwE,aAAa,CAACtC,IAAI,CAAC0C,EAAE,CAAC;UACxB;QACF,CAAC,CAAC;MACJ,CAAC,CAAC;MAEF,IAAAE,uBAAe,EAACP,eAAe,CAAC;MAChCrD,GAAG,IAAI,IAAA6D,iBAAY,EAAC,IAAI,EAAE7D,GAAG,EAAEyC,aAAa,EAAEa,aAAa,CAAC;IAC9D;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -40,7 +40,8 @@ jest.mock('fizban', () => ({
|
|
|
40
40
|
}));
|
|
41
41
|
describe('interact', () => {
|
|
42
42
|
let element;
|
|
43
|
-
|
|
43
|
+
let mockConfig;
|
|
44
|
+
const getMockConfig = () => ({
|
|
44
45
|
interactions: [{
|
|
45
46
|
trigger: 'viewEnter',
|
|
46
47
|
key: 'logo-entrance',
|
|
@@ -247,7 +248,7 @@ describe('interact', () => {
|
|
|
247
248
|
duration: 500
|
|
248
249
|
}
|
|
249
250
|
}
|
|
250
|
-
};
|
|
251
|
+
});
|
|
251
252
|
beforeEach(() => {
|
|
252
253
|
element = document.createElement('wix-interact-element');
|
|
253
254
|
const div = document.createElement('div');
|
|
@@ -396,22 +397,40 @@ describe('interact', () => {
|
|
|
396
397
|
// Reset forceReducedMotion to default
|
|
397
398
|
_Interact.Interact.forceReducedMotion = false;
|
|
398
399
|
});
|
|
399
|
-
describe('init Interact', () => {
|
|
400
|
+
describe('init Interact instance', () => {
|
|
400
401
|
it('should initialize with valid config', () => {
|
|
401
402
|
_Interact.Interact.create({});
|
|
402
403
|
expect(customElements.get('wix-interact-element')).toBeDefined();
|
|
403
404
|
});
|
|
404
405
|
});
|
|
406
|
+
describe('destroy Interact instance', () => {
|
|
407
|
+
it('should clear an instance entire cache', () => {
|
|
408
|
+
const instance = _Interact.Interact.create(getMockConfig());
|
|
409
|
+
element = document.createElement('wix-interact-element');
|
|
410
|
+
element.dataset.wixPath = 'logo-entrance';
|
|
411
|
+
const div = document.createElement('div');
|
|
412
|
+
element.append(div);
|
|
413
|
+
(0, _add.add)(element, 'logo-entrance');
|
|
414
|
+
expect(Object.keys(instance.dataCache.interactions).length).toBe(11);
|
|
415
|
+
expect(instance.elements.size).toBe(1);
|
|
416
|
+
expect(_Interact.Interact.instances.length).toBe(1);
|
|
417
|
+
instance.destroy();
|
|
418
|
+
expect(Object.keys(instance.dataCache.interactions).length).toBe(0);
|
|
419
|
+
expect(instance.elements.size).toBe(0);
|
|
420
|
+
expect(_Interact.Interact.instances.length).toBe(0);
|
|
421
|
+
expect(_Interact.Interact.elementCache.size).toBe(0);
|
|
422
|
+
});
|
|
423
|
+
});
|
|
405
424
|
describe('destroy Interact', () => {
|
|
406
425
|
it('should clear all instances', () => {
|
|
407
|
-
_Interact.Interact.create(
|
|
408
|
-
_Interact.Interact.create(
|
|
426
|
+
_Interact.Interact.create(getMockConfig());
|
|
427
|
+
_Interact.Interact.create(getMockConfig());
|
|
409
428
|
expect(_Interact.Interact.instances.length).toBe(2);
|
|
410
429
|
_Interact.Interact.destroy();
|
|
411
430
|
expect(_Interact.Interact.instances.length).toBe(0);
|
|
412
431
|
});
|
|
413
432
|
it('should clear all elements from cache', () => {
|
|
414
|
-
_Interact.Interact.create(
|
|
433
|
+
_Interact.Interact.create(getMockConfig());
|
|
415
434
|
element = document.createElement('wix-interact-element');
|
|
416
435
|
const div = document.createElement('div');
|
|
417
436
|
element.append(div);
|
|
@@ -421,7 +440,7 @@ describe('interact', () => {
|
|
|
421
440
|
expect(_Interact.Interact.elementCache.size).toBe(0);
|
|
422
441
|
});
|
|
423
442
|
it('should call disconnect on all cached elements', () => {
|
|
424
|
-
_Interact.Interact.create(
|
|
443
|
+
_Interact.Interact.create(getMockConfig());
|
|
425
444
|
const element1 = document.createElement('wix-interact-element');
|
|
426
445
|
const div1 = document.createElement('div');
|
|
427
446
|
element1.append(div1);
|
|
@@ -437,7 +456,7 @@ describe('interact', () => {
|
|
|
437
456
|
expect(disconnectSpy2).toHaveBeenCalled();
|
|
438
457
|
});
|
|
439
458
|
it('should clean up interactions after destroy', () => {
|
|
440
|
-
_Interact.Interact.create(
|
|
459
|
+
_Interact.Interact.create(getMockConfig());
|
|
441
460
|
element = document.createElement('wix-interact-element');
|
|
442
461
|
const div = document.createElement('div');
|
|
443
462
|
element.append(div);
|
|
@@ -448,7 +467,7 @@ describe('interact', () => {
|
|
|
448
467
|
expect(_Interact.Interact.getInstance('logo-click')).toBeUndefined();
|
|
449
468
|
|
|
450
469
|
// Re-create instance and verify it works independently
|
|
451
|
-
_Interact.Interact.create(
|
|
470
|
+
_Interact.Interact.create(getMockConfig());
|
|
452
471
|
const newElement = document.createElement('wix-interact-element');
|
|
453
472
|
const newDiv = document.createElement('div');
|
|
454
473
|
newElement.append(newDiv);
|
|
@@ -516,11 +535,12 @@ describe('interact', () => {
|
|
|
516
535
|
reducedMotion: true
|
|
517
536
|
});
|
|
518
537
|
_Interact.Interact.forceReducedMotion = false;
|
|
519
|
-
|
|
538
|
+
_Interact.Interact.destroy();
|
|
520
539
|
});
|
|
521
540
|
});
|
|
522
541
|
describe('add interaction', () => {
|
|
523
542
|
beforeEach(() => {
|
|
543
|
+
mockConfig = getMockConfig();
|
|
524
544
|
_Interact.Interact.create(mockConfig);
|
|
525
545
|
});
|
|
526
546
|
afterEach(() => {
|
|
@@ -536,6 +556,7 @@ describe('interact', () => {
|
|
|
536
556
|
const div = document.createElement('div');
|
|
537
557
|
element.append(div);
|
|
538
558
|
const addEventListenerSpy = jest.spyOn(div, 'addEventListener');
|
|
559
|
+
expect(getWebAnimation).toHaveBeenCalledTimes(0);
|
|
539
560
|
(0, _add.add)(element, 'logo-hover');
|
|
540
561
|
expect(addEventListenerSpy).toHaveBeenCalledTimes(4);
|
|
541
562
|
expect(addEventListenerSpy).toHaveBeenCalledWith('mouseenter', expect.any(Function), expect.objectContaining({
|
|
@@ -589,18 +610,20 @@ describe('interact', () => {
|
|
|
589
610
|
} = require('@wix/motion');
|
|
590
611
|
element = document.createElement('wix-interact-element');
|
|
591
612
|
const div = document.createElement('div');
|
|
613
|
+
div.id = 'logo-entrance';
|
|
592
614
|
element.dataset.wixPath = 'logo-entrance';
|
|
593
615
|
element.append(div);
|
|
594
616
|
const elementClick = document.createElement('wix-interact-element');
|
|
595
617
|
const divClick = document.createElement('div');
|
|
618
|
+
divClick.id = 'logo-click';
|
|
596
619
|
elementClick.dataset.wixPath = 'logo-click';
|
|
597
620
|
elementClick.append(divClick);
|
|
598
621
|
(0, _add.add)(elementClick, 'logo-click');
|
|
599
622
|
(0, _add.add)(element, 'logo-entrance');
|
|
600
623
|
expect(getWebAnimation).toHaveBeenCalledTimes(3);
|
|
601
624
|
expect(getWebAnimation.mock.calls[0][0]).toBe(divClick);
|
|
602
|
-
expect(getWebAnimation.mock.calls[1][0]).toBe(
|
|
603
|
-
expect(getWebAnimation.mock.calls[2][0]).toBe(
|
|
625
|
+
expect(getWebAnimation.mock.calls[1][0]).toBe(divClick);
|
|
626
|
+
expect(getWebAnimation.mock.calls[2][0]).toBe(div);
|
|
604
627
|
expect(getWebAnimation.mock.calls[0][3]).toMatchObject({
|
|
605
628
|
reducedMotion: false
|
|
606
629
|
});
|
|
@@ -660,7 +683,7 @@ describe('interact', () => {
|
|
|
660
683
|
element.append(div);
|
|
661
684
|
(0, _add.add)(element, 'logo-mouse');
|
|
662
685
|
expect(getScrubScene).toHaveBeenCalledTimes(1);
|
|
663
|
-
expect(getScrubScene).toHaveBeenCalledWith(expect.any(HTMLElement), expect.objectContaining((0, _utilities.effectToAnimationOptions)(
|
|
686
|
+
expect(getScrubScene).toHaveBeenCalledWith(expect.any(HTMLElement), expect.objectContaining((0, _utilities.effectToAnimationOptions)(getMockConfig().effects['logo-track-mouse'])), expect.objectContaining({
|
|
664
687
|
trigger: 'pointer-move'
|
|
665
688
|
}));
|
|
666
689
|
expect(pointerInstance.start).toHaveBeenCalled();
|
|
@@ -676,7 +699,7 @@ describe('interact', () => {
|
|
|
676
699
|
element.append(div);
|
|
677
700
|
(0, _add.add)(element, 'logo-scroll');
|
|
678
701
|
expect(getWebAnimation).toHaveBeenCalledTimes(1);
|
|
679
|
-
expect(getWebAnimation).toHaveBeenCalledWith(expect.any(HTMLElement), expect.objectContaining((0, _utilities.effectToAnimationOptions)(
|
|
702
|
+
expect(getWebAnimation).toHaveBeenCalledWith(expect.any(HTMLElement), expect.objectContaining((0, _utilities.effectToAnimationOptions)(getMockConfig().effects['logo-fade-scroll'])), expect.objectContaining({
|
|
680
703
|
trigger: 'view-progress'
|
|
681
704
|
}));
|
|
682
705
|
});
|
|
@@ -699,7 +722,7 @@ describe('interact', () => {
|
|
|
699
722
|
element.append(div);
|
|
700
723
|
(0, _add.add)(element, 'logo-scroll');
|
|
701
724
|
expect(getScrubScene).toHaveBeenCalledTimes(1);
|
|
702
|
-
expect(getScrubScene).toHaveBeenCalledWith(expect.any(HTMLElement), expect.objectContaining((0, _utilities.effectToAnimationOptions)(
|
|
725
|
+
expect(getScrubScene).toHaveBeenCalledWith(expect.any(HTMLElement), expect.objectContaining((0, _utilities.effectToAnimationOptions)(getMockConfig().effects['logo-fade-scroll'])), expect.objectContaining({
|
|
703
726
|
trigger: 'view-progress'
|
|
704
727
|
}));
|
|
705
728
|
setTimeout(() => {
|
|
@@ -802,17 +825,17 @@ describe('interact', () => {
|
|
|
802
825
|
expect(getWebAnimation).toHaveBeenCalledTimes(0);
|
|
803
826
|
(0, _add.add)(targetElement, 'logo-scroll-items');
|
|
804
827
|
expect(getWebAnimation).toHaveBeenCalledTimes(2);
|
|
805
|
-
expect(getWebAnimation).toHaveBeenCalledWith(li, expect.objectContaining((0, _utilities.effectToAnimationOptions)(
|
|
828
|
+
expect(getWebAnimation).toHaveBeenCalledWith(li, expect.objectContaining((0, _utilities.effectToAnimationOptions)(getMockConfig().effects['logo-fade-scroll'])), expect.objectContaining({
|
|
806
829
|
trigger: 'view-progress'
|
|
807
830
|
}));
|
|
808
|
-
expect(getWebAnimation).toHaveBeenCalledWith(li2, expect.objectContaining((0, _utilities.effectToAnimationOptions)(
|
|
831
|
+
expect(getWebAnimation).toHaveBeenCalledWith(li2, expect.objectContaining((0, _utilities.effectToAnimationOptions)(getMockConfig().effects['logo-fade-scroll'])), expect.objectContaining({
|
|
809
832
|
trigger: 'view-progress'
|
|
810
833
|
}));
|
|
811
834
|
const li3 = document.createElement('li');
|
|
812
835
|
ul.append(li3);
|
|
813
836
|
(0, _add.addListItems)(targetElement, 'logo-scroll-items', '#logo-scroll-list', [li3]);
|
|
814
837
|
expect(getWebAnimation).toHaveBeenCalledTimes(3);
|
|
815
|
-
expect(getWebAnimation).toHaveBeenCalledWith(li3, expect.objectContaining((0, _utilities.effectToAnimationOptions)(
|
|
838
|
+
expect(getWebAnimation).toHaveBeenCalledWith(li3, expect.objectContaining((0, _utilities.effectToAnimationOptions)(getMockConfig().effects['logo-fade-scroll'])), expect.objectContaining({
|
|
816
839
|
trigger: 'view-progress'
|
|
817
840
|
}));
|
|
818
841
|
});
|
|
@@ -820,7 +843,10 @@ describe('interact', () => {
|
|
|
820
843
|
});
|
|
821
844
|
describe('remove interaction', () => {
|
|
822
845
|
beforeEach(() => {
|
|
823
|
-
_Interact.Interact.create(
|
|
846
|
+
_Interact.Interact.create(getMockConfig());
|
|
847
|
+
});
|
|
848
|
+
afterEach(() => {
|
|
849
|
+
_Interact.Interact.destroy();
|
|
824
850
|
});
|
|
825
851
|
it('should remove event listeners', () => {
|
|
826
852
|
element = document.createElement('wix-interact-element');
|