@wix/interact 1.85.0 → 1.89.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/README.md +7 -7
- package/dist/cjs/{WixInteractElement.js → InteractElement.js} +14 -14
- package/dist/cjs/InteractElement.js.map +1 -0
- package/dist/cjs/__tests__/interact.spec.js +81 -55
- package/dist/cjs/__tests__/interact.spec.js.map +1 -1
- package/dist/cjs/__tests__/viewEnter.spec.js +207 -0
- package/dist/cjs/__tests__/viewEnter.spec.js.map +1 -0
- package/dist/cjs/core/Interact.js +19 -7
- package/dist/cjs/core/Interact.js.map +1 -1
- package/dist/cjs/core/add.js +3 -3
- package/dist/cjs/core/add.js.map +1 -1
- package/dist/cjs/handlers/click.js +3 -3
- package/dist/cjs/handlers/click.js.map +1 -1
- package/dist/cjs/handlers/hover.js +4 -4
- package/dist/cjs/handlers/hover.js.map +1 -1
- package/dist/cjs/handlers/pointerMove.js +8 -2
- package/dist/cjs/handlers/pointerMove.js.map +1 -1
- package/dist/cjs/handlers/utilities.js +0 -2
- package/dist/cjs/handlers/utilities.js.map +1 -1
- package/dist/cjs/handlers/viewEnter.js +63 -11
- package/dist/cjs/handlers/viewEnter.js.map +1 -1
- package/dist/cjs/handlers/viewProgress.js +9 -3
- package/dist/cjs/handlers/viewProgress.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils.js +2 -2
- package/dist/cjs/utils.js.map +1 -1
- package/dist/esm/{WixInteractElement.js → InteractElement.js} +12 -12
- package/dist/esm/InteractElement.js.map +1 -0
- package/dist/esm/__tests__/interact.spec.js +80 -55
- package/dist/esm/__tests__/interact.spec.js.map +1 -1
- package/dist/esm/__tests__/viewEnter.spec.js +210 -0
- package/dist/esm/__tests__/viewEnter.spec.js.map +1 -0
- package/dist/esm/core/Interact.js +19 -7
- package/dist/esm/core/Interact.js.map +1 -1
- package/dist/esm/core/add.js +3 -3
- package/dist/esm/core/add.js.map +1 -1
- package/dist/esm/handlers/click.js +3 -3
- package/dist/esm/handlers/click.js.map +1 -1
- package/dist/esm/handlers/hover.js +4 -4
- package/dist/esm/handlers/hover.js.map +1 -1
- package/dist/esm/handlers/pointerMove.js +8 -2
- package/dist/esm/handlers/pointerMove.js.map +1 -1
- package/dist/esm/handlers/utilities.js +0 -2
- package/dist/esm/handlers/utilities.js.map +1 -1
- package/dist/esm/handlers/viewEnter.js +65 -11
- package/dist/esm/handlers/viewEnter.js.map +1 -1
- package/dist/esm/handlers/viewProgress.js +9 -3
- package/dist/esm/handlers/viewProgress.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils.js +2 -2
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/{WixInteractElement.d.ts → InteractElement.d.ts} +2 -2
- package/dist/types/__tests__/viewEnter.spec.d.ts +0 -0
- package/dist/types/core/Interact.d.ts +11 -6
- package/dist/types/core/add.d.ts +3 -3
- package/dist/types/handlers/pointerMove.d.ts +2 -0
- package/dist/types/handlers/viewEnter.d.ts +2 -0
- package/dist/types/handlers/viewProgress.d.ts +2 -0
- package/dist/types/types.d.ts +8 -3
- package/package.json +7 -6
- package/dist/cjs/WixInteractElement.js.map +0 -1
- package/dist/esm/WixInteractElement.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_motion","require","_utilities","handlerMap","WeakMap","createTimeEffectHandler","element","effect","options","reducedMotion","animation","getAnimation","effectToAnimationOptions","undefined","type","initialPlay","event","play","reverse","playState","progress","isCSS","onFinish","dataset","motionEnter","cancel","pause","createTransitionHandler","effectId","listContainer","listItemSelector","method","isToggle","shouldSetStateOnElement","
|
|
1
|
+
{"version":3,"names":["_motion","require","_utilities","handlerMap","WeakMap","createTimeEffectHandler","element","effect","options","reducedMotion","animation","getAnimation","effectToAnimationOptions","undefined","type","initialPlay","event","play","reverse","playState","progress","isCSS","onFinish","dataset","motionEnter","cancel","pause","createTransitionHandler","effectId","listContainer","listItemSelector","method","isToggle","shouldSetStateOnElement","interactElement","closest","item","method_","toggleEffect","addHoverHandler","source","target","handler","isStateTrigger","once","transition","transitionProperties","cleanup","removeEventListener","handlerObj","addHandlerToMap","addEventListener","passive","addLeave","removeHoverHandler","removeElementFromHandlerMap","_default","exports","default","add","remove"],"sources":["../../../src/handlers/hover.ts"],"sourcesContent":["import type { AnimationGroup } from '@wix/motion';\nimport { getAnimation } from '@wix/motion';\nimport type {\n TimeEffect,\n TransitionEffect,\n StateParams,\n HandlerObjectMap,\n IInteractElement,\n PointerTriggerParams,\n EffectBase,\n} from '../types';\nimport {\n effectToAnimationOptions,\n addHandlerToMap,\n removeElementFromHandlerMap,\n} from './utilities';\n\nconst handlerMap = new WeakMap() as HandlerObjectMap;\n\nfunction createTimeEffectHandler(\n element: HTMLElement,\n effect: TimeEffect & EffectBase,\n options: PointerTriggerParams,\n reducedMotion: boolean = false,\n) {\n const animation = getAnimation(\n element,\n effectToAnimationOptions(effect),\n undefined,\n reducedMotion,\n ) as AnimationGroup;\n const type = options.type || 'alternate';\n let initialPlay = true;\n\n return (event: MouseEvent) => {\n if (event.type === 'mouseenter') {\n if (type === 'alternate') {\n if (initialPlay) {\n initialPlay = false;\n animation.play();\n } else {\n animation.reverse();\n }\n } else if (type === 'state') {\n if (animation.playState !== 'finished') {\n // 'idle' OR 'paused'\n animation.play();\n }\n } else {\n // type === 'repeat'\n // type === 'once'\n animation.progress(0);\n\n if (animation.isCSS) {\n animation.onFinish(() => {\n element.dataset.motionEnter = 'done';\n });\n }\n\n animation.play();\n }\n } else if (event.type === 'mouseleave') {\n if (type === 'alternate') {\n animation.reverse();\n } else if (type === 'repeat') {\n animation.cancel();\n delete element.dataset.motionEnter;\n } else if (type === 'state') {\n if (animation.playState === 'running') {\n animation.pause();\n }\n }\n }\n };\n}\n\nfunction createTransitionHandler(\n element: HTMLElement,\n {\n effectId,\n listContainer,\n listItemSelector,\n }: TransitionEffect & EffectBase & { effectId: string },\n options: StateParams,\n) {\n const method = options.method || 'toggle';\n const isToggle = method === 'toggle';\n const shouldSetStateOnElement = !!listContainer;\n\n return (event: MouseEvent) => {\n const interactElement = element.closest(\n 'interact-element',\n ) as IInteractElement;\n if (!interactElement) {\n return;\n }\n\n let item;\n if (shouldSetStateOnElement) {\n item = element.closest(\n `${listContainer} > ${listItemSelector || ''}:has(:scope)`,\n ) as HTMLElement | null;\n }\n\n if (event.type === 'mouseenter') {\n const method_ = isToggle ? 'add' : method;\n interactElement.toggleEffect(effectId, method_, item);\n } else if (event.type === 'mouseleave' && isToggle) {\n interactElement.toggleEffect(effectId, 'remove', item);\n }\n };\n}\n\nfunction addHoverHandler(\n source: HTMLElement,\n target: HTMLElement,\n effect: (TransitionEffect | TimeEffect) & EffectBase,\n options: StateParams | PointerTriggerParams = {},\n reducedMotion: boolean = false,\n) {\n let handler: (event: MouseEvent) => void;\n let isStateTrigger = false;\n let once = false;\n\n if (\n (effect as TransitionEffect).transition ||\n (effect as TransitionEffect).transitionProperties\n ) {\n handler = createTransitionHandler(\n target,\n effect as TransitionEffect & EffectBase & { effectId: string },\n options as StateParams,\n );\n isStateTrigger = true;\n } else {\n handler = createTimeEffectHandler(\n target,\n effect as TimeEffect & EffectBase,\n options as PointerTriggerParams,\n reducedMotion,\n );\n once = (options as PointerTriggerParams).type === 'once';\n }\n\n const cleanup = () => {\n source.removeEventListener('mouseenter', handler);\n source.removeEventListener('mouseleave', handler);\n };\n\n const handlerObj = { source, target, cleanup };\n\n addHandlerToMap(handlerMap, source, handlerObj);\n addHandlerToMap(handlerMap, target, handlerObj);\n\n source.addEventListener('mouseenter', handler, { passive: true, once });\n\n const addLeave = isStateTrigger\n ? ((options as StateParams).method || 'toggle') === 'toggle'\n : (options as PointerTriggerParams).type !== 'once';\n if (addLeave) {\n source.addEventListener('mouseleave', handler, { passive: true });\n }\n}\n\nfunction removeHoverHandler(element: HTMLElement) {\n removeElementFromHandlerMap(handlerMap, element);\n}\n\nexport default {\n add: addHoverHandler,\n remove: removeHoverHandler,\n};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AM,CAACW,gBAAgB,CAAC,YAAY,EAAET,OAAO,EAAE;MAAEU,OAAO,EAAE;IAAK,CAAC,CAAC;EACnE;AACF;AAEA,SAASE,kBAAkBA,CAAChD,OAAoB,EAAE;EAChD,IAAAiD,sCAA2B,EAACpD,UAAU,EAAEG,OAAO,CAAC;AAClD;AAAC,IAAAkD,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc;EACbC,GAAG,EAAEpB,eAAe;EACpBqB,MAAM,EAAEN;AACV,CAAC","ignoreList":[]}
|
|
@@ -6,6 +6,10 @@ var _motion = require("@wix/motion");
|
|
|
6
6
|
var _kuliso = require("kuliso");
|
|
7
7
|
var _utilities = require("./utilities");
|
|
8
8
|
const pointerManagerMap = new WeakMap();
|
|
9
|
+
let pointerOptionsGetter = () => ({});
|
|
10
|
+
function registerOptionsGetter(getter) {
|
|
11
|
+
pointerOptionsGetter = getter;
|
|
12
|
+
}
|
|
9
13
|
function addPointerMoveHandler(source, target, effect, options = {}, reducedMotion = false) {
|
|
10
14
|
if (reducedMotion) {
|
|
11
15
|
return;
|
|
@@ -18,7 +22,8 @@ function addPointerMoveHandler(source, target, effect, options = {}, reducedMoti
|
|
|
18
22
|
if (scene) {
|
|
19
23
|
const pointer = new _kuliso.Pointer({
|
|
20
24
|
root: options.hitArea === 'root' ? document.documentElement : source,
|
|
21
|
-
scenes: Array.isArray(scene) ? scene : [scene]
|
|
25
|
+
scenes: Array.isArray(scene) ? scene : [scene],
|
|
26
|
+
...pointerOptionsGetter()
|
|
22
27
|
});
|
|
23
28
|
const cleanup = () => {
|
|
24
29
|
pointer.destroy();
|
|
@@ -38,6 +43,7 @@ function removePointerMoveHandler(element) {
|
|
|
38
43
|
}
|
|
39
44
|
var _default = exports.default = {
|
|
40
45
|
add: addPointerMoveHandler,
|
|
41
|
-
remove: removePointerMoveHandler
|
|
46
|
+
remove: removePointerMoveHandler,
|
|
47
|
+
registerOptionsGetter
|
|
42
48
|
};
|
|
43
49
|
//# sourceMappingURL=pointerMove.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_motion","require","_kuliso","_utilities","pointerManagerMap","WeakMap","addPointerMoveHandler","source","target","effect","options","reducedMotion","triggerParams","trigger","element","scene","getScrubScene","effectToAnimationOptions","pointer","Pointer","root","hitArea","document","documentElement","scenes","Array","isArray","cleanup","destroy","handlerObj","addHandlerToMap","start","removePointerMoveHandler","removeElementFromHandlerMap","_default","exports","default","add","remove"],"sources":["../../../src/handlers/pointerMove.ts"],"sourcesContent":["import { getScrubScene } from '@wix/motion';\nimport { Pointer } from 'kuliso';\nimport type {\n PointerMoveParams,\n ScrubEffect,\n HandlerObjectMap,\n} from '../types';\nimport {\n effectToAnimationOptions,\n addHandlerToMap,\n removeElementFromHandlerMap,\n} from './utilities';\n\nconst pointerManagerMap = new WeakMap() as HandlerObjectMap;\n\nfunction addPointerMoveHandler(\n source: HTMLElement,\n target: HTMLElement,\n effect: ScrubEffect,\n options: PointerMoveParams = {},\n reducedMotion: boolean = false,\n) {\n if (reducedMotion) {\n return;\n }\n\n const triggerParams = {\n trigger: 'pointer-move' as const,\n element: source,\n };\n\n const scene = getScrubScene(\n target,\n effectToAnimationOptions(effect),\n triggerParams,\n );\n\n if (scene) {\n const pointer = new Pointer({\n root: options.hitArea === 'root' ? document.documentElement : source,\n scenes: Array.isArray(scene) ? scene : [scene],\n });\n const cleanup = () => {\n pointer.destroy();\n };\n\n const handlerObj = { source, target, cleanup };\n\n addHandlerToMap(pointerManagerMap, source, handlerObj);\n addHandlerToMap(pointerManagerMap, target, handlerObj);\n\n pointer.start();\n }\n}\n\nfunction removePointerMoveHandler(element: HTMLElement) {\n removeElementFromHandlerMap(pointerManagerMap, element);\n}\n\nexport default {\n add: addPointerMoveHandler,\n remove: removePointerMoveHandler,\n};\n"],"mappings":";;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMA,IAAAE,UAAA,GAAAF,OAAA;AAMA,MAAMG,iBAAiB,GAAG,IAAIC,OAAO,CAAC,CAAqB;
|
|
1
|
+
{"version":3,"names":["_motion","require","_kuliso","_utilities","pointerManagerMap","WeakMap","pointerOptionsGetter","registerOptionsGetter","getter","addPointerMoveHandler","source","target","effect","options","reducedMotion","triggerParams","trigger","element","scene","getScrubScene","effectToAnimationOptions","pointer","Pointer","root","hitArea","document","documentElement","scenes","Array","isArray","cleanup","destroy","handlerObj","addHandlerToMap","start","removePointerMoveHandler","removeElementFromHandlerMap","_default","exports","default","add","remove"],"sources":["../../../src/handlers/pointerMove.ts"],"sourcesContent":["import { getScrubScene } from '@wix/motion';\nimport { Pointer, PointerConfig } from 'kuliso';\nimport type {\n PointerMoveParams,\n ScrubEffect,\n HandlerObjectMap,\n} from '../types';\nimport {\n effectToAnimationOptions,\n addHandlerToMap,\n removeElementFromHandlerMap,\n} from './utilities';\n\nconst pointerManagerMap = new WeakMap() as HandlerObjectMap;\nlet pointerOptionsGetter: () => Partial<PointerConfig> = () => ({});\n\nfunction registerOptionsGetter(getter: () => Partial<PointerConfig>) {\n pointerOptionsGetter = getter;\n}\n\nfunction addPointerMoveHandler(\n source: HTMLElement,\n target: HTMLElement,\n effect: ScrubEffect,\n options: PointerMoveParams = {},\n reducedMotion: boolean = false,\n) {\n if (reducedMotion) {\n return;\n }\n\n const triggerParams = {\n trigger: 'pointer-move' as const,\n element: source,\n };\n\n const scene = getScrubScene(\n target,\n effectToAnimationOptions(effect),\n triggerParams,\n );\n\n if (scene) {\n const pointer = new Pointer({\n root: options.hitArea === 'root' ? document.documentElement : source,\n scenes: Array.isArray(scene) ? scene : [scene],\n ...pointerOptionsGetter(),\n });\n const cleanup = () => {\n pointer.destroy();\n };\n\n const handlerObj = { source, target, cleanup };\n\n addHandlerToMap(pointerManagerMap, source, handlerObj);\n addHandlerToMap(pointerManagerMap, target, handlerObj);\n\n pointer.start();\n }\n}\n\nfunction removePointerMoveHandler(element: HTMLElement) {\n removeElementFromHandlerMap(pointerManagerMap, element);\n}\n\nexport default {\n add: addPointerMoveHandler,\n remove: removePointerMoveHandler,\n registerOptionsGetter,\n};\n"],"mappings":";;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMA,IAAAE,UAAA,GAAAF,OAAA;AAMA,MAAMG,iBAAiB,GAAG,IAAIC,OAAO,CAAC,CAAqB;AAC3D,IAAIC,oBAAkD,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC;AAEnE,SAASC,qBAAqBA,CAACC,MAAoC,EAAE;EACnEF,oBAAoB,GAAGE,MAAM;AAC/B;AAEA,SAASC,qBAAqBA,CAC5BC,MAAmB,EACnBC,MAAmB,EACnBC,MAAmB,EACnBC,OAA0B,GAAG,CAAC,CAAC,EAC/BC,aAAsB,GAAG,KAAK,EAC9B;EACA,IAAIA,aAAa,EAAE;IACjB;EACF;EAEA,MAAMC,aAAa,GAAG;IACpBC,OAAO,EAAE,cAAuB;IAChCC,OAAO,EAAEP;EACX,CAAC;EAED,MAAMQ,KAAK,GAAG,IAAAC,qBAAa,EACzBR,MAAM,EACN,IAAAS,mCAAwB,EAACR,MAAM,CAAC,EAChCG,aACF,CAAC;EAED,IAAIG,KAAK,EAAE;IACT,MAAMG,OAAO,GAAG,IAAIC,eAAO,CAAC;MAC1BC,IAAI,EAAEV,OAAO,CAACW,OAAO,KAAK,MAAM,GAAGC,QAAQ,CAACC,eAAe,GAAGhB,MAAM;MACpEiB,MAAM,EAAEC,KAAK,CAACC,OAAO,CAACX,KAAK,CAAC,GAAGA,KAAK,GAAG,CAACA,KAAK,CAAC;MAC9C,GAAGZ,oBAAoB,CAAC;IAC1B,CAAC,CAAC;IACF,MAAMwB,OAAO,GAAGA,CAAA,KAAM;MACpBT,OAAO,CAACU,OAAO,CAAC,CAAC;IACnB,CAAC;IAED,MAAMC,UAAU,GAAG;MAAEtB,MAAM;MAAEC,MAAM;MAAEmB;IAAQ,CAAC;IAE9C,IAAAG,0BAAe,EAAC7B,iBAAiB,EAAEM,MAAM,EAAEsB,UAAU,CAAC;IACtD,IAAAC,0BAAe,EAAC7B,iBAAiB,EAAEO,MAAM,EAAEqB,UAAU,CAAC;IAEtDX,OAAO,CAACa,KAAK,CAAC,CAAC;EACjB;AACF;AAEA,SAASC,wBAAwBA,CAAClB,OAAoB,EAAE;EACtD,IAAAmB,sCAA2B,EAAChC,iBAAiB,EAAEa,OAAO,CAAC;AACzD;AAAC,IAAAoB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc;EACbC,GAAG,EAAE/B,qBAAqB;EAC1BgC,MAAM,EAAEN,wBAAwB;EAChC5B;AACF,CAAC","ignoreList":[]}
|
|
@@ -7,7 +7,6 @@ exports.removeElementFromHandlerMap = removeElementFromHandlerMap;
|
|
|
7
7
|
function effectToAnimationOptions(effect) {
|
|
8
8
|
if (effect.duration) {
|
|
9
9
|
return {
|
|
10
|
-
type: 'TimeAnimationOptions',
|
|
11
10
|
id: '',
|
|
12
11
|
...effect
|
|
13
12
|
};
|
|
@@ -18,7 +17,6 @@ function effectToAnimationOptions(effect) {
|
|
|
18
17
|
...rest
|
|
19
18
|
} = effect;
|
|
20
19
|
return {
|
|
21
|
-
type: 'ScrubAnimationOptions',
|
|
22
20
|
id: '',
|
|
23
21
|
startOffset: rangeStart,
|
|
24
22
|
endOffset: rangeEnd,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["effectToAnimationOptions","effect","duration","
|
|
1
|
+
{"version":3,"names":["effectToAnimationOptions","effect","duration","id","rangeStart","rangeEnd","rest","startOffset","endOffset","addHandlerToMap","handlersMap","element","handlerObj","handlers","get","Set","set","add","removeElementFromHandlerMap","handlerMap","forEach","source","target","cleanup","otherKey","otherHandlers","delete"],"sources":["../../../src/handlers/utilities.ts"],"sourcesContent":["import type {\n TimeEffect,\n ScrubEffect,\n HandlerObject,\n HandlerObjectMap,\n AnimationOptions,\n} from '../types';\n\nexport function effectToAnimationOptions(effect: TimeEffect | ScrubEffect) {\n if ((effect as TimeEffect).duration) {\n return {\n id: '',\n ...effect,\n } as AnimationOptions<'time'>;\n }\n\n const { rangeStart, rangeEnd, ...rest } = effect as ScrubEffect;\n return {\n id: '',\n startOffset: rangeStart,\n endOffset: rangeEnd,\n ...rest,\n } as AnimationOptions<'scrub'>;\n}\n\nexport function addHandlerToMap(\n handlersMap: HandlerObjectMap,\n element: HTMLElement,\n handlerObj: HandlerObject,\n) {\n let handlers = handlersMap.get(element);\n\n if (!handlers) {\n handlers = new Set();\n handlersMap.set(element, handlers);\n }\n\n handlers.add(handlerObj);\n}\n\nexport function removeElementFromHandlerMap(\n handlerMap: HandlerObjectMap,\n element: HTMLElement,\n) {\n const handlers = handlerMap.get(element);\n\n handlers?.forEach((handlerObj) => {\n const { source, target, cleanup } = handlerObj;\n cleanup();\n\n const otherKey = source === element ? target : source;\n const otherHandlers = handlerMap.get(otherKey);\n otherHandlers?.delete(handlerObj);\n });\n\n handlerMap.delete(element);\n}\n"],"mappings":";;;;;;AAQO,SAASA,wBAAwBA,CAACC,MAAgC,EAAE;EACzE,IAAKA,MAAM,CAAgBC,QAAQ,EAAE;IACnC,OAAO;MACLC,EAAE,EAAE,EAAE;MACN,GAAGF;IACL,CAAC;EACH;EAEA,MAAM;IAAEG,UAAU;IAAEC,QAAQ;IAAE,GAAGC;EAAK,CAAC,GAAGL,MAAqB;EAC/D,OAAO;IACLE,EAAE,EAAE,EAAE;IACNI,WAAW,EAAEH,UAAU;IACvBI,SAAS,EAAEH,QAAQ;IACnB,GAAGC;EACL,CAAC;AACH;AAEO,SAASG,eAAeA,CAC7BC,WAA6B,EAC7BC,OAAoB,EACpBC,UAAyB,EACzB;EACA,IAAIC,QAAQ,GAAGH,WAAW,CAACI,GAAG,CAACH,OAAO,CAAC;EAEvC,IAAI,CAACE,QAAQ,EAAE;IACbA,QAAQ,GAAG,IAAIE,GAAG,CAAC,CAAC;IACpBL,WAAW,CAACM,GAAG,CAACL,OAAO,EAAEE,QAAQ,CAAC;EACpC;EAEAA,QAAQ,CAACI,GAAG,CAACL,UAAU,CAAC;AAC1B;AAEO,SAASM,2BAA2BA,CACzCC,UAA4B,EAC5BR,OAAoB,EACpB;EACA,MAAME,QAAQ,GAAGM,UAAU,CAACL,GAAG,CAACH,OAAO,CAAC;EAExCE,QAAQ,YAARA,QAAQ,CAAEO,OAAO,CAAER,UAAU,IAAK;IAChC,MAAM;MAAES,MAAM;MAAEC,MAAM;MAAEC;IAAQ,CAAC,GAAGX,UAAU;IAC9CW,OAAO,CAAC,CAAC;IAET,MAAMC,QAAQ,GAAGH,MAAM,KAAKV,OAAO,GAAGW,MAAM,GAAGD,MAAM;IACrD,MAAMI,aAAa,GAAGN,UAAU,CAACL,GAAG,CAACU,QAAQ,CAAC;IAC9CC,aAAa,YAAbA,aAAa,CAAEC,MAAM,CAACd,UAAU,CAAC;EACnC,CAAC,CAAC;EAEFO,UAAU,CAACO,MAAM,CAACf,OAAO,CAAC;AAC5B","ignoreList":[]}
|
|
@@ -1,20 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
exports.__esModule = true;
|
|
4
5
|
exports.default = void 0;
|
|
5
6
|
var _motion = require("@wix/motion");
|
|
6
7
|
var _utilities = require("./utilities");
|
|
8
|
+
var _fastdom = _interopRequireDefault(require("fastdom"));
|
|
9
|
+
const SAFE_OBSERVER_CONFIG = {
|
|
10
|
+
root: null,
|
|
11
|
+
rootMargin: '0px 0px -10% 0px',
|
|
12
|
+
threshold: [0]
|
|
13
|
+
};
|
|
7
14
|
const observers = {};
|
|
8
15
|
const handlerMap = new WeakMap();
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
const elementFirstRun = new WeakSet();
|
|
17
|
+
const elementObserverMap = new WeakMap();
|
|
18
|
+
let viewEnterOptions = {};
|
|
19
|
+
function setOptions(options) {
|
|
20
|
+
viewEnterOptions = options;
|
|
21
|
+
}
|
|
22
|
+
function getObserver(options, isSafeMode = false) {
|
|
23
|
+
const key = JSON.stringify({
|
|
24
|
+
...options,
|
|
25
|
+
isSafeMode
|
|
26
|
+
});
|
|
11
27
|
if (observers[key]) {
|
|
12
28
|
return observers[key];
|
|
13
29
|
}
|
|
30
|
+
const config = isSafeMode ? SAFE_OBSERVER_CONFIG : {
|
|
31
|
+
root: null,
|
|
32
|
+
rootMargin: options.inset ? `${options.inset} 0px ${options.inset}` : '0px',
|
|
33
|
+
threshold: options.threshold
|
|
34
|
+
};
|
|
14
35
|
const observer = new IntersectionObserver(entries => {
|
|
15
36
|
entries.forEach(entry => {
|
|
37
|
+
const target = entry.target;
|
|
38
|
+
const isFirstRun = !elementFirstRun.has(target);
|
|
39
|
+
if (isFirstRun) {
|
|
40
|
+
elementFirstRun.add(target);
|
|
41
|
+
if (options.useSafeViewEnter && !entry.isIntersecting) {
|
|
42
|
+
_fastdom.default.measure(() => {
|
|
43
|
+
var _entry$rootBounds;
|
|
44
|
+
const sourceHeight = entry.boundingClientRect.height;
|
|
45
|
+
const rootHeight = (_entry$rootBounds = entry.rootBounds) == null ? void 0 : _entry$rootBounds.height;
|
|
46
|
+
if (!rootHeight) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const threshold = Array.isArray(options.threshold) ? Math.min(...options.threshold) : options.threshold;
|
|
50
|
+
const needsSafeObserver = threshold && sourceHeight * threshold > rootHeight;
|
|
51
|
+
if (needsSafeObserver) {
|
|
52
|
+
_fastdom.default.mutate(() => {
|
|
53
|
+
observer.unobserve(target);
|
|
54
|
+
const safeObserver = getObserver(options, true);
|
|
55
|
+
elementObserverMap.set(target, safeObserver);
|
|
56
|
+
safeObserver.observe(target);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
16
63
|
if (entry.isIntersecting) {
|
|
17
|
-
const handlers = handlerMap.get(
|
|
64
|
+
const handlers = handlerMap.get(target);
|
|
18
65
|
handlers == null || handlers.forEach(({
|
|
19
66
|
source,
|
|
20
67
|
handler
|
|
@@ -25,19 +72,19 @@ function getObserver(options) {
|
|
|
25
72
|
});
|
|
26
73
|
if (options.type === 'once') {
|
|
27
74
|
observer.unobserve(entry.target);
|
|
75
|
+
elementFirstRun.delete(target);
|
|
28
76
|
}
|
|
29
77
|
}
|
|
30
78
|
});
|
|
31
|
-
},
|
|
32
|
-
root: null,
|
|
33
|
-
rootMargin: options.inset ? `${options.inset} 0px ${options.inset}` : '0px',
|
|
34
|
-
threshold: options.threshold
|
|
35
|
-
});
|
|
79
|
+
}, config);
|
|
36
80
|
observers[key] = observer;
|
|
37
81
|
return observer;
|
|
38
82
|
}
|
|
39
83
|
function addViewEnterHandler(source, target, effect, options = {}, reducedMotion = false) {
|
|
40
|
-
const observer = getObserver(
|
|
84
|
+
const observer = getObserver({
|
|
85
|
+
...viewEnterOptions,
|
|
86
|
+
...options
|
|
87
|
+
});
|
|
41
88
|
const animation = (0, _motion.getAnimation)(target, (0, _utilities.effectToAnimationOptions)(effect), undefined, reducedMotion);
|
|
42
89
|
if (animation != null && animation.isCSS && options.type === 'once') {
|
|
43
90
|
animation.onFinish(() => {
|
|
@@ -52,8 +99,11 @@ function addViewEnterHandler(source, target, effect, options = {}, reducedMotion
|
|
|
52
99
|
});
|
|
53
100
|
};
|
|
54
101
|
const cleanup = () => {
|
|
55
|
-
|
|
102
|
+
const currentObserver = elementObserverMap.get(source) || observer;
|
|
103
|
+
currentObserver.unobserve(source);
|
|
56
104
|
animation.cancel();
|
|
105
|
+
elementFirstRun.delete(source);
|
|
106
|
+
elementObserverMap.delete(source);
|
|
57
107
|
};
|
|
58
108
|
const handlerObj = {
|
|
59
109
|
source,
|
|
@@ -63,6 +113,7 @@ function addViewEnterHandler(source, target, effect, options = {}, reducedMotion
|
|
|
63
113
|
};
|
|
64
114
|
(0, _utilities.addHandlerToMap)(handlerMap, source, handlerObj);
|
|
65
115
|
(0, _utilities.addHandlerToMap)(handlerMap, target, handlerObj);
|
|
116
|
+
elementObserverMap.set(source, observer);
|
|
66
117
|
observer.observe(source);
|
|
67
118
|
}
|
|
68
119
|
function removeViewEnterHandler(element) {
|
|
@@ -70,6 +121,7 @@ function removeViewEnterHandler(element) {
|
|
|
70
121
|
}
|
|
71
122
|
var _default = exports.default = {
|
|
72
123
|
add: addViewEnterHandler,
|
|
73
|
-
remove: removeViewEnterHandler
|
|
124
|
+
remove: removeViewEnterHandler,
|
|
125
|
+
setOptions
|
|
74
126
|
};
|
|
75
127
|
//# sourceMappingURL=viewEnter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_motion","require","_utilities","observers","handlerMap","WeakMap","
|
|
1
|
+
{"version":3,"names":["_motion","require","_utilities","_fastdom","_interopRequireDefault","SAFE_OBSERVER_CONFIG","root","rootMargin","threshold","observers","handlerMap","WeakMap","elementFirstRun","WeakSet","elementObserverMap","viewEnterOptions","setOptions","options","getObserver","isSafeMode","key","JSON","stringify","config","inset","observer","IntersectionObserver","entries","forEach","entry","target","isFirstRun","has","add","useSafeViewEnter","isIntersecting","fastdom","measure","_entry$rootBounds","sourceHeight","boundingClientRect","height","rootHeight","rootBounds","Array","isArray","Math","min","needsSafeObserver","mutate","unobserve","safeObserver","set","observe","handlers","get","source","handler","type","delete","addViewEnterHandler","effect","reducedMotion","animation","getAnimation","effectToAnimationOptions","undefined","isCSS","onFinish","dataset","motionEnter","play","cleanup","currentObserver","cancel","handlerObj","addHandlerToMap","removeViewEnterHandler","element","removeElementFromHandlerMap","_default","exports","default","remove"],"sources":["../../../src/handlers/viewEnter.ts"],"sourcesContent":["import type { AnimationGroup } from '@wix/motion';\nimport { getAnimation } from '@wix/motion';\nimport type { TimeEffect, HandlerObjectMap, ViewEnterParams } from '../types';\nimport {\n effectToAnimationOptions,\n addHandlerToMap,\n removeElementFromHandlerMap,\n} from './utilities';\nimport fastdom from 'fastdom';\n\nconst SAFE_OBSERVER_CONFIG: IntersectionObserverInit = {\n root: null,\n rootMargin: '0px 0px -10% 0px',\n threshold: [0],\n};\n\nconst observers: Record<string, IntersectionObserver> = {};\nconst handlerMap = new WeakMap() as HandlerObjectMap;\nconst elementFirstRun = new WeakSet<HTMLElement>();\nconst elementObserverMap = new WeakMap<HTMLElement, IntersectionObserver>();\nlet viewEnterOptions: Partial<ViewEnterParams> = {};\n\nfunction setOptions(options: Partial<ViewEnterParams>) {\n viewEnterOptions = options;\n}\n\nfunction getObserver(options: ViewEnterParams, isSafeMode: boolean = false) {\n const key = JSON.stringify({ ...options, isSafeMode });\n\n if (observers[key]) {\n return observers[key];\n }\n\n const config: IntersectionObserverInit = isSafeMode\n ? SAFE_OBSERVER_CONFIG\n : {\n root: null,\n rootMargin: options.inset\n ? `${options.inset} 0px ${options.inset}`\n : '0px',\n threshold: options.threshold,\n };\n\n const observer = new IntersectionObserver((entries) => {\n entries.forEach((entry) => {\n const target = entry.target as HTMLElement;\n const isFirstRun = !elementFirstRun.has(target);\n\n if (isFirstRun) {\n elementFirstRun.add(target);\n\n if (options.useSafeViewEnter && !entry.isIntersecting) {\n fastdom.measure(() => {\n const sourceHeight = entry.boundingClientRect.height;\n const rootHeight = entry.rootBounds?.height;\n\n if (!rootHeight) {\n return;\n }\n\n const threshold = Array.isArray(options.threshold)\n ? Math.min(...options.threshold)\n : options.threshold;\n\n const needsSafeObserver =\n threshold && sourceHeight * threshold > rootHeight;\n\n if (needsSafeObserver) {\n fastdom.mutate(() => {\n observer.unobserve(target);\n const safeObserver = getObserver(options, true);\n elementObserverMap.set(target, safeObserver);\n safeObserver.observe(target);\n });\n }\n });\n return;\n }\n }\n\n if (entry.isIntersecting) {\n const handlers = handlerMap.get(target);\n\n handlers?.forEach(({ source, handler }) => {\n if (source === entry.target) {\n handler!();\n }\n });\n\n if (options.type === 'once') {\n observer.unobserve(entry.target);\n elementFirstRun.delete(target);\n }\n }\n });\n }, config);\n\n observers[key] = observer;\n\n return observer;\n}\n\nfunction addViewEnterHandler(\n source: HTMLElement,\n target: HTMLElement,\n effect: TimeEffect,\n options: ViewEnterParams = {},\n reducedMotion: boolean = false,\n) {\n const observer = getObserver({ ...viewEnterOptions, ...options });\n const animation = getAnimation(\n target,\n effectToAnimationOptions(effect),\n undefined,\n reducedMotion,\n ) as AnimationGroup;\n\n if (animation?.isCSS && options.type === 'once') {\n animation.onFinish(() => {\n target.dataset.motionEnter = 'done';\n });\n }\n\n const handler = () => {\n animation.play(() => {\n if (!animation.isCSS) {\n target.dataset.motionEnter = 'done';\n }\n });\n };\n const cleanup = () => {\n const currentObserver = elementObserverMap.get(source) || observer;\n currentObserver.unobserve(source);\n animation.cancel();\n elementFirstRun.delete(source);\n elementObserverMap.delete(source);\n };\n const handlerObj = { source, target, handler, cleanup };\n\n addHandlerToMap(handlerMap, source, handlerObj);\n addHandlerToMap(handlerMap, target, handlerObj);\n\n elementObserverMap.set(source, observer);\n observer.observe(source);\n}\n\nfunction removeViewEnterHandler(element: HTMLElement) {\n removeElementFromHandlerMap(handlerMap, element);\n}\n\nexport default {\n add: addViewEnterHandler,\n remove: removeViewEnterHandler,\n setOptions,\n};\n"],"mappings":";;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,MAAMI,oBAA8C,GAAG;EACrDC,IAAI,EAAE,IAAI;EACVC,UAAU,EAAE,kBAAkB;EAC9BC,SAAS,EAAE,CAAC,CAAC;AACf,CAAC;AAED,MAAMC,SAA+C,GAAG,CAAC,CAAC;AAC1D,MAAMC,UAAU,GAAG,IAAIC,OAAO,CAAC,CAAqB;AACpD,MAAMC,eAAe,GAAG,IAAIC,OAAO,CAAc,CAAC;AAClD,MAAMC,kBAAkB,GAAG,IAAIH,OAAO,CAAoC,CAAC;AAC3E,IAAII,gBAA0C,GAAG,CAAC,CAAC;AAEnD,SAASC,UAAUA,CAACC,OAAiC,EAA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AACI,MAAM,EAAE/B,QAAQ,CAAC;EACxCA,QAAQ,CAAC4B,OAAO,CAACG,MAAM,CAAC;AAC1B;AAEA,SAASqB,sBAAsBA,CAACC,OAAoB,EAAE;EACpD,IAAAC,sCAA2B,EAACrE,UAAU,EAAEoE,OAAO,CAAC;AAClD;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc;EACbjD,GAAG,EAAE2B,mBAAmB;EACxBuB,MAAM,EAAEN,sBAAsB;EAC9B7D;AACF,CAAC","ignoreList":[]}
|
|
@@ -6,6 +6,10 @@ var _motion = require("@wix/motion");
|
|
|
6
6
|
var _fizban = require("fizban");
|
|
7
7
|
var _utilities = require("./utilities");
|
|
8
8
|
const scrollManagerMap = new WeakMap();
|
|
9
|
+
let scrollOptionsGetter = () => ({});
|
|
10
|
+
function registerOptionsGetter(getter) {
|
|
11
|
+
scrollOptionsGetter = getter;
|
|
12
|
+
}
|
|
9
13
|
function addViewProgressHandler(source, target, effect, __, reducedMotion = false) {
|
|
10
14
|
if (reducedMotion) {
|
|
11
15
|
return;
|
|
@@ -30,8 +34,9 @@ function addViewProgressHandler(source, target, effect, __, reducedMotion = fals
|
|
|
30
34
|
scenes,
|
|
31
35
|
observeViewportEntry: false,
|
|
32
36
|
observeViewportResize: false,
|
|
33
|
-
observeSourcesResize:
|
|
34
|
-
root: document.
|
|
37
|
+
observeSourcesResize: true,
|
|
38
|
+
root: document.body,
|
|
39
|
+
...scrollOptionsGetter()
|
|
35
40
|
});
|
|
36
41
|
const cleanup = () => {
|
|
37
42
|
scroll.destroy();
|
|
@@ -54,6 +59,7 @@ function removeViewProgressHandler(element) {
|
|
|
54
59
|
}
|
|
55
60
|
var _default = exports.default = {
|
|
56
61
|
add: addViewProgressHandler,
|
|
57
|
-
remove: removeViewProgressHandler
|
|
62
|
+
remove: removeViewProgressHandler,
|
|
63
|
+
registerOptionsGetter
|
|
58
64
|
};
|
|
59
65
|
//# sourceMappingURL=viewProgress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_motion","require","_fizban","_utilities","scrollManagerMap","WeakMap","addViewProgressHandler","source","target","effect","__","reducedMotion","triggerParams","trigger","element","effectOptions","effectToAnimationOptions","window","animationGroup","getWebAnimation","play","scene","getScrubScene","scenes","Array","isArray","scroll","Scroll","viewSource","observeViewportEntry","observeViewportResize","observeSourcesResize","root","document","
|
|
1
|
+
{"version":3,"names":["_motion","require","_fizban","_utilities","scrollManagerMap","WeakMap","scrollOptionsGetter","registerOptionsGetter","getter","addViewProgressHandler","source","target","effect","__","reducedMotion","triggerParams","trigger","element","effectOptions","effectToAnimationOptions","window","animationGroup","getWebAnimation","play","scene","getScrubScene","scenes","Array","isArray","scroll","Scroll","viewSource","observeViewportEntry","observeViewportResize","observeSourcesResize","root","document","body","cleanup","destroy","handlerObj","addHandlerToMap","Promise","all","map","s","ready","resolve","then","start","removeViewProgressHandler","removeElementFromHandlerMap","_default","exports","default","add","remove"],"sources":["../../../src/handlers/viewProgress.ts"],"sourcesContent":["import type { ScrubScrollScene } from '@wix/motion';\nimport { getWebAnimation, getScrubScene } from '@wix/motion';\nimport { Scroll, scrollConfig } from 'fizban';\nimport type { ViewEnterParams, ScrubEffect, HandlerObjectMap } from '../types';\nimport {\n effectToAnimationOptions,\n addHandlerToMap,\n removeElementFromHandlerMap,\n} from './utilities';\n\nconst scrollManagerMap = new WeakMap() as HandlerObjectMap;\nlet scrollOptionsGetter: () => Partial<scrollConfig> = () => ({});\n\nfunction registerOptionsGetter(getter: () => scrollConfig) {\n scrollOptionsGetter = getter;\n}\n\nfunction addViewProgressHandler(\n source: HTMLElement,\n target: HTMLElement,\n effect: ScrubEffect,\n __: ViewEnterParams,\n reducedMotion: boolean = false,\n): void {\n if (reducedMotion) {\n return;\n }\n\n const triggerParams = {\n trigger: 'view-progress' as const,\n element: source,\n };\n\n const effectOptions = effectToAnimationOptions(effect);\n\n if ('ViewTimeline' in window) {\n // Use ViewTimeline for modern browsers\n const animationGroup = getWebAnimation(\n target,\n effectOptions,\n triggerParams,\n );\n\n if (animationGroup) {\n (animationGroup as any).play();\n }\n } else {\n const scene = getScrubScene(target, effectOptions, triggerParams);\n\n if (scene) {\n const scenes = Array.isArray(scene) ? scene : [scene];\n const scroll = new Scroll({\n viewSource: source,\n scenes,\n observeViewportEntry: false,\n observeViewportResize: false,\n observeSourcesResize: true,\n root: document.body,\n ...scrollOptionsGetter(),\n });\n\n const cleanup = () => {\n scroll.destroy();\n };\n\n const handlerObj = { source, target, cleanup };\n\n addHandlerToMap(scrollManagerMap, source, handlerObj);\n addHandlerToMap(scrollManagerMap, target, handlerObj);\n\n Promise.all(\n (scenes as ScrubScrollScene[]).map((s) => s.ready || Promise.resolve()),\n ).then(() => {\n scroll.start();\n });\n }\n }\n}\n\nfunction removeViewProgressHandler(element: HTMLElement): void {\n removeElementFromHandlerMap(scrollManagerMap, element);\n}\n\nexport default {\n add: addViewProgressHandler,\n remove: removeViewProgressHandler,\n registerOptionsGetter,\n};\n"],"mappings":";;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AAMA,MAAMG,gBAAgB,GAAG,IAAIC,OAAO,CAAC,CAAqB;AAC1D,IAAIC,mBAAgD,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC;AAEjE,SAASC,qBAAqBA,CAACC,MAA0B,EAAE;EACzDF,mBAAmB,GAAGE,MAAM;AAC9B;AAEA,SAASC,sBAAsBA,CAC7BC,MAAmB,EACnBC,MAAmB,EACnBC,MAAmB,EACnBC,EAAmB,EACnBC,aAAsB,GAAG,KAAK,EACxB;EACN,IAAIA,aAAa,EAAE;IACjB;EACF;EAEA,MAAMC,aAAa,GAAG;IACpBC,OAAO,EAAE,eAAwB;IACjCC,OAAO,EAAEP;EACX,CAAC;EAED,MAAMQ,aAAa,GAAG,IAAAC,mCAAwB,EAACP,MAAM,CAAC;EAEtD,IAAI,c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C,OAAoB,EAAQ;EAC7D,IAAAkC,sCAA2B,EAAC/C,gBAAgB,EAAEa,OAAO,CAAC;AACxD;AAAC,IAAAmC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc;EACbC,GAAG,EAAE9C,sBAAsB;EAC3B+C,MAAM,EAAEN,yBAAyB;EACjC3C;AACF,CAAC","ignoreList":[]}
|
package/dist/cjs/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/types.ts"],"sourcesContent":["import type {\n NamedEffect,\n RangeOffset,\n ScrubTransitionEasing,\n MotionAnimationOptions,\n} from '@wix/motion';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n '
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/types.ts"],"sourcesContent":["import type {\n NamedEffect,\n RangeOffset,\n ScrubTransitionEasing,\n MotionAnimationOptions,\n} from '@wix/motion';\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'interact-element': React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLElement>,\n HTMLElement\n > & {\n 'data-interact-key'?: string;\n };\n }\n }\n}\n\nexport type TriggerType =\n | 'hover'\n | 'click'\n | 'viewEnter'\n | 'pageVisible'\n | 'animationEnd'\n | 'viewProgress'\n | 'pointerMove';\n\nexport type ViewEnterType = 'once' | 'repeat' | 'alternate';\n\nexport type TransitionMethod = 'add' | 'remove' | 'toggle' | 'clear';\n\nexport type StateParams = {\n method: TransitionMethod;\n};\n\nexport type PointerTriggerParams = {\n type?: ViewEnterType | 'state';\n};\n\nexport type ViewEnterParams = {\n type?: ViewEnterType;\n threshold?: number;\n inset?: string;\n useSafeViewEnter?: boolean;\n};\n\nexport type PointerMoveParams = {\n hitArea?: 'root' | 'self';\n};\n\nexport type AnimationEndParams = {\n effectId: string;\n};\n\nexport type TriggerParams =\n | StateParams\n | PointerTriggerParams\n | ViewEnterParams\n | PointerMoveParams\n | AnimationEndParams;\n\ntype Fill = 'none' | 'forwards' | 'backwards' | 'both';\n\ntype MotionKeyframeEffect = {\n name: string;\n keyframes: Keyframe[];\n};\n\ntype EffectEffectProperty =\n | {\n keyframeEffect: MotionKeyframeEffect;\n }\n | {\n namedEffect: NamedEffect;\n }\n | {\n customEffect: (element: Element, progress: any) => void;\n };\n\nexport type TimeEffect = {\n duration: number;\n easing?: string;\n iterations?: number;\n alternate?: boolean;\n fill?: Fill;\n reversed?: boolean;\n delay?: number;\n} & EffectEffectProperty;\n\nexport type ScrubEffect = {\n easing?: string;\n iterations?: number;\n alternate?: boolean;\n fill?: Fill;\n reversed?: boolean;\n rangeStart?: RangeOffset;\n rangeEnd?: RangeOffset;\n centeredToTarget?: boolean;\n transitionDuration?: number;\n transitionDelay?: number;\n transitionEasing?: ScrubTransitionEasing;\n} & EffectEffectProperty;\n\nexport type TransitionOptions = {\n duration?: number;\n delay?: number;\n easing?: string;\n};\n\nexport type StyleProperty = {\n name: string;\n value: string;\n};\n\nexport type TransitionProperty = StyleProperty & TransitionOptions;\n\nexport type TransitionEffect = {\n key?: string;\n effectId?: string;\n} & {\n transition?: TransitionOptions & {\n styleProperties: StyleProperty[];\n };\n transitionProperties?: TransitionProperty[];\n};\n\nexport type EffectBase = {\n key?: string;\n listContainer?: string;\n listItemSelector?: string;\n conditions?: string[];\n selector?: string;\n effectId?: string;\n};\n\nexport type EffectRef = EffectBase & { effectId: string };\n\nexport type Effect = EffectBase & (TimeEffect | ScrubEffect | TransitionEffect);\n\nexport type Condition = {\n type: 'media' | 'container';\n predicate?: string;\n};\n\nexport type InteractionTrigger = {\n key: string;\n listContainer?: string;\n listItemSelector?: string;\n trigger: TriggerType;\n params?: TriggerParams;\n conditions?: string[];\n selector?: string;\n};\n\nexport type Interaction = InteractionTrigger & {\n effects: ((Effect | EffectRef) & { interactionId?: string })[];\n};\n\nexport type InteractConfig = {\n effects: Record<string, Effect>;\n conditions?: Record<string, Condition>;\n interactions: Interaction[];\n};\n\nexport type AnimationOptions<T extends 'time' | 'scrub'> =\n MotionAnimationOptions<T> & EffectEffectProperty;\n\n/// ////////////////////////////////////////////////////////\n/// ////////////////////////////////////////////////////////\n/// ////////////////////////////////////////////////////////\n\nexport interface IInteractElement extends HTMLElement {\n _internals: (ElementInternals & { states: Set<string> }) | null;\n connected: boolean;\n sheet: CSSStyleSheet | null;\n _observers: WeakMap<HTMLElement, MutationObserver>;\n connectedCallback(): void;\n disconnectedCallback(): void;\n connect(path?: string): void;\n disconnect(): void;\n renderStyle(cssRules: string[]): void;\n toggleEffect(\n effectId: string,\n method: StateParams['method'],\n item?: HTMLElement | null,\n ): void;\n watchChildList(listContainer: string): void;\n}\n\nexport type InteractionParamsTypes = {\n hover: StateParams | PointerTriggerParams;\n click: StateParams | PointerTriggerParams;\n viewEnter: ViewEnterParams;\n pageVisible: ViewEnterParams;\n animationEnd: AnimationEndParams;\n viewProgress: ViewEnterParams;\n pointerMove: PointerMoveParams;\n};\n\nexport type InteractionHandlerModule<T extends TriggerType> = {\n registerOptionsGetter?: (getter: () => any) => void;\n add: (\n source: HTMLElement,\n target: HTMLElement,\n effect: Effect,\n options: InteractionParamsTypes[T],\n reducedMotion?: boolean,\n ) => void;\n remove: (element: HTMLElement) => void;\n};\n\nexport type ViewEnterHandlerModule = InteractionHandlerModule<'viewEnter'> & {\n setOptions: (options: Partial<ViewEnterParams>) => void;\n};\n\nexport type TriggerHandlerMap<T extends TriggerType> = {\n [K in T]: InteractionHandlerModule<K>;\n};\n\nexport type HandlerObject = {\n source: HTMLElement;\n target: HTMLElement;\n cleanup: () => void;\n handler?: () => void;\n};\n\nexport type HandlerObjectMap = WeakMap<HTMLElement, Set<HandlerObject>>;\n\nexport type InteractCache = {\n effects: {\n [effectId: string]: Effect;\n };\n conditions: {\n [conditionId: string]: Condition;\n };\n interactions: {\n [path: string]: {\n triggers: Interaction[];\n effects: Record<\n string,\n (InteractionTrigger & { effect: Effect | EffectRef })[]\n >;\n interactionIds: Set<string>;\n selectors: Set<string>;\n };\n };\n};\n\nexport type CreateTransitionCSSParams = {\n key: string;\n effectId: string;\n transition?: TransitionEffect['transition'];\n properties?: TransitionProperty[];\n childSelector?: string;\n};\n"],"mappings":"","ignoreList":[]}
|
package/dist/cjs/utils.js
CHANGED
|
@@ -41,12 +41,12 @@ function createTransitionCSS({
|
|
|
41
41
|
const styleProperties = ((_properties2 = properties) == null ? void 0 : _properties2.map(property => `${property.name}: ${property.value};`)) || [];
|
|
42
42
|
const escapedKey = key.replace(/"/g, "'");
|
|
43
43
|
const result = [`:is(:state(${effectId}), :--${effectId}) ${childSelector},
|
|
44
|
-
[data-
|
|
44
|
+
[data-interact-effect~="${effectId}"] ${childSelector} {
|
|
45
45
|
${styleProperties.join(`
|
|
46
46
|
`)}
|
|
47
47
|
}`];
|
|
48
48
|
if (transitions.length) {
|
|
49
|
-
result.push(`@media (prefers-reduced-motion: no-preference) { [data-
|
|
49
|
+
result.push(`@media (prefers-reduced-motion: no-preference) { [data-interact-key="${escapedKey}"] ${childSelector} {
|
|
50
50
|
transition: ${transitions.join(', ')};
|
|
51
51
|
} }`);
|
|
52
52
|
}
|
package/dist/cjs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_motion","require","generateId","replace","c","String","fromCharCode","crypto","getRandomValues","Uint8Array","createTransitionCSS","key","effectId","transition","properties","childSelector","_properties2","transitions","styleProperties","duration","easing","delay","hasCustomPropertiesTransition","some","styleProperty","name","startsWith","getEasing","map","_properties","filter","property","value","escapedKey","result","join","length","push","getMediaQuery","conditionNames","conditions","conditionContent","conditionName","_conditions$condition","type","predicate","condition","mql","window","matchMedia"],"sources":["../../src/utils.ts"],"sourcesContent":["import { getEasing } from '@wix/motion';\nimport type { Condition, CreateTransitionCSSParams } from './types';\n\nexport function generateId() {\n return 'wi-12343210'.replace(\n /\\d/g,\n (c) =>\n String.fromCharCode(\n (+c ^\n (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))) +\n 97,\n ), // 97 for \"a\"\n );\n}\n\nexport function createTransitionCSS({\n key,\n effectId,\n transition,\n properties,\n childSelector = '> :first-child',\n}: CreateTransitionCSSParams): string[] {\n let transitions: string[] = [];\n\n if (transition?.styleProperties) {\n const { duration, easing, delay } = transition;\n\n if (duration) {\n const hasCustomPropertiesTransition = transition.styleProperties.some(\n (styleProperty) => styleProperty.name.startsWith('--'),\n );\n\n if (hasCustomPropertiesTransition) {\n // If there are custom properties in the transition, we need to fall back to Viewer's legacy implementation\n transitions = [\n `all ${duration}ms ${getEasing(easing || 'ease')}${\n delay ? ` ${delay}ms` : ''\n }`,\n 'visibility 0s',\n ];\n } else {\n transitions = transition.styleProperties.map(\n (styleProperty) =>\n `${styleProperty.name} ${duration}ms ${getEasing(\n easing || 'ease',\n )}${delay ? ` ${delay}ms` : ''}`,\n );\n }\n }\n\n properties = transition.styleProperties;\n } else {\n transitions =\n properties\n ?.filter((property) => property.duration)\n .map(\n (property) =>\n `${property.name} ${property.duration}ms ${\n getEasing(property.easing) || 'ease'\n }${property.delay ? ` ${property.delay}ms` : ''}`,\n ) || [];\n }\n\n const styleProperties =\n properties?.map((property) => `${property.name}: ${property.value};`) || [];\n const escapedKey = key.replace(/\"/g, \"'\");\n\n const result = [\n `:is(:state(${effectId}), :--${effectId}) ${childSelector},\n [data-
|
|
1
|
+
{"version":3,"names":["_motion","require","generateId","replace","c","String","fromCharCode","crypto","getRandomValues","Uint8Array","createTransitionCSS","key","effectId","transition","properties","childSelector","_properties2","transitions","styleProperties","duration","easing","delay","hasCustomPropertiesTransition","some","styleProperty","name","startsWith","getEasing","map","_properties","filter","property","value","escapedKey","result","join","length","push","getMediaQuery","conditionNames","conditions","conditionContent","conditionName","_conditions$condition","type","predicate","condition","mql","window","matchMedia"],"sources":["../../src/utils.ts"],"sourcesContent":["import { getEasing } from '@wix/motion';\nimport type { Condition, CreateTransitionCSSParams } from './types';\n\nexport function generateId() {\n return 'wi-12343210'.replace(\n /\\d/g,\n (c) =>\n String.fromCharCode(\n (+c ^\n (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))) +\n 97,\n ), // 97 for \"a\"\n );\n}\n\nexport function createTransitionCSS({\n key,\n effectId,\n transition,\n properties,\n childSelector = '> :first-child',\n}: CreateTransitionCSSParams): string[] {\n let transitions: string[] = [];\n\n if (transition?.styleProperties) {\n const { duration, easing, delay } = transition;\n\n if (duration) {\n const hasCustomPropertiesTransition = transition.styleProperties.some(\n (styleProperty) => styleProperty.name.startsWith('--'),\n );\n\n if (hasCustomPropertiesTransition) {\n // If there are custom properties in the transition, we need to fall back to Viewer's legacy implementation\n transitions = [\n `all ${duration}ms ${getEasing(easing || 'ease')}${\n delay ? ` ${delay}ms` : ''\n }`,\n 'visibility 0s',\n ];\n } else {\n transitions = transition.styleProperties.map(\n (styleProperty) =>\n `${styleProperty.name} ${duration}ms ${getEasing(\n easing || 'ease',\n )}${delay ? ` ${delay}ms` : ''}`,\n );\n }\n }\n\n properties = transition.styleProperties;\n } else {\n transitions =\n properties\n ?.filter((property) => property.duration)\n .map(\n (property) =>\n `${property.name} ${property.duration}ms ${\n getEasing(property.easing) || 'ease'\n }${property.delay ? ` ${property.delay}ms` : ''}`,\n ) || [];\n }\n\n const styleProperties =\n properties?.map((property) => `${property.name}: ${property.value};`) || [];\n const escapedKey = key.replace(/\"/g, \"'\");\n\n const result = [\n `:is(:state(${effectId}), :--${effectId}) ${childSelector},\n [data-interact-effect~=\"${effectId}\"] ${childSelector} {\n ${styleProperties.join(`\n `)}\n }`,\n ];\n\n if (transitions.length) {\n result.push(`@media (prefers-reduced-motion: no-preference) { [data-interact-key=\"${escapedKey}\"] ${childSelector} {\n transition: ${transitions.join(', ')};\n } }`);\n }\n return result;\n}\n\nexport function getMediaQuery(\n conditionNames: string[] | undefined,\n conditions: Record<string, Condition>,\n) {\n const conditionContent = (conditionNames || [])\n .filter((conditionName) => {\n return (\n conditions[conditionName]?.type === 'media' &&\n conditions[conditionName].predicate\n );\n })\n .map((conditionName) => {\n return conditions[conditionName].predicate;\n })\n .join(') and (');\n\n const condition = conditionContent && `(${conditionContent})`;\n const mql = condition && window.matchMedia(condition);\n\n if (mql) {\n return mql;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAGO,SAASC,UAAUA,CAAA,EAAG;EAC3B,OAAO,aAAa,CAACC,OAAO,CAC1B,KAAK,EACJC,CAAC,IACAC,MAAM,CAACC,YAAY,CACjB,CAAC,CAACF,CAAC,GACAG,MAAM,CAACC,eAAe,CAAC,IAAIC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAI,EAAE,IAAK,CAACL,CAAC,GAAG,CAAI,IACjE,EACJ,CAAC,CAAE;EACP,CAAC;AACH;AAEO,SAASM,mBAAmBA,CAAC;EAClCC,GAAG;EACHC,QAAQ;EACRC,UAAU;EACVC,UAAU;EACVC,aAAa,GAAG;AACS,CAAC,EAAY;EAAA,IAAAC,YAAA;EACtC,IAAIC,WAAqB,GAAG,EAAE;EAE9B,IAAIJ,UAAU,YAAVA,UAAU,CAAEK,eAAe,EAAE;IAC/B,MAAM;MAAEC,QAAQ;MAAEC,MAAM;MAAEC;IAAM,CAAC,GAAGR,UAAU;IAE9C,IAAIM,QAAQ,EAAE;MACZ,MAAMG,6BAA6B,GAAGT,UAAU,CAACK,eAAe,CAACK,IAAI,CAClEC,aAAa,IAAKA,aAAa,CAACC,IAAI,CAACC,UAAU,CAAC,IAAI,CACvD,CAAC;MAED,IAAIJ,6BAA6B,EAAE;QACjC;QACAL,WAAW,GAAG,CACZ,OAAOE,QAAQ,MAAM,IAAAQ,iBAAS,EAACP,MAAM,IAAI,MAAM,CAAC,GAC9CC,KAAK,GAAG,IAAIA,KAAK,IAAI,GAAG,EAAE,EAC1B,EACF,eAAe,CAChB;MACH,CAAC,MAAM;QACLJ,WAAW,GAAGJ,UAAU,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AAI,CAAC,IAAI,CAAC;AAC1C,QAAQ,CAAC;EACP;EACA,OAAOD,MAAM;AACf;AAEO,SAASI,aAAaA,CAC3BC,cAAoC,EACpCC,UAAqC,EACrC;EACA,MAAMC,gBAAgB,GAAG,CAACF,cAAc,IAAI,EAAE,EAC3CT,MAAM,CAAEY,aAAa,IAAK;IAAA,IAAAC,qBAAA;IACzB,OACE,EAAAA,qBAAA,GAAAH,UAAU,CAACE,aAAa,CAAC,qBAAzBC,qBAAA,CAA2BC,IAAI,MAAK,OAAO,IAC3CJ,UAAU,CAACE,aAAa,CAAC,CAACG,SAAS;EAEvC,CAAC,CAAC,CACDjB,GAAG,CAAEc,aAAa,IAAK;IACtB,OAAOF,UAAU,CAACE,aAAa,CAAC,CAACG,SAAS;EAC5C,CAAC,CAAC,CACDV,IAAI,CAAC,SAAS,CAAC;EAElB,MAAMW,SAAS,GAAGL,gBAAgB,IAAI,IAAIA,gBAAgB,GAAG;EAC7D,MAAMM,GAAG,GAAGD,SAAS,IAAIE,MAAM,CAACC,UAAU,CAACH,SAAS,CAAC;EAErD,IAAIC,GAAG,EAAE;IACP,OAAOA,GAAG;EACZ;AACF","ignoreList":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { add, addListItems } from './core/add';
|
|
3
3
|
import { remove, removeListItems } from './core/remove';
|
|
4
|
-
export const
|
|
5
|
-
export function
|
|
4
|
+
export const INTERACT_EFFECT_DATA_ATTR = 'interactEffect';
|
|
5
|
+
export function getInteractElement() {
|
|
6
6
|
let checkedForLegacyStateSyntax = false;
|
|
7
7
|
let isLegacyStateSyntax = false;
|
|
8
|
-
return class
|
|
8
|
+
return class InteractElement extends HTMLElement {
|
|
9
9
|
constructor() {
|
|
10
10
|
super();
|
|
11
11
|
_defineProperty(this, "_internals", void 0);
|
|
@@ -38,7 +38,7 @@ export function getWixInteractElement() {
|
|
|
38
38
|
this.disconnect();
|
|
39
39
|
}
|
|
40
40
|
disconnect() {
|
|
41
|
-
const key = this.dataset.
|
|
41
|
+
const key = this.dataset.interactKey;
|
|
42
42
|
if (key) {
|
|
43
43
|
remove(key);
|
|
44
44
|
}
|
|
@@ -53,9 +53,9 @@ export function getWixInteractElement() {
|
|
|
53
53
|
if (this.connected) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
key = key || this.dataset.
|
|
56
|
+
key = key || this.dataset.interactKey;
|
|
57
57
|
if (!key) {
|
|
58
|
-
console.warn('
|
|
58
|
+
console.warn('InteractElement: No key provided');
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
this.connected = add(this, key);
|
|
@@ -95,8 +95,8 @@ export function getWixInteractElement() {
|
|
|
95
95
|
this._internals.states.clear();
|
|
96
96
|
}
|
|
97
97
|
} else {
|
|
98
|
-
var _this$dataset$
|
|
99
|
-
const currentEffects = new Set(((_this$dataset$
|
|
98
|
+
var _this$dataset$INTERAC;
|
|
99
|
+
const currentEffects = new Set(((_this$dataset$INTERAC = this.dataset[INTERACT_EFFECT_DATA_ATTR]) == null ? void 0 : _this$dataset$INTERAC.split(' ')) || []);
|
|
100
100
|
if (method === 'toggle') {
|
|
101
101
|
currentEffects.has(effectId) ? currentEffects.delete(effectId) : currentEffects.add(effectId);
|
|
102
102
|
} else if (method === 'add') {
|
|
@@ -106,7 +106,7 @@ export function getWixInteractElement() {
|
|
|
106
106
|
} else if (method === 'clear') {
|
|
107
107
|
currentEffects.clear();
|
|
108
108
|
}
|
|
109
|
-
(item || this).dataset[
|
|
109
|
+
(item || this).dataset[INTERACT_EFFECT_DATA_ATTR] = Array.from(currentEffects).join(' ');
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
getActiveEffects() {
|
|
@@ -114,7 +114,7 @@ export function getWixInteractElement() {
|
|
|
114
114
|
const effects = Array.from(this._internals.states);
|
|
115
115
|
return isLegacyStateSyntax ? effects.map(effect => effect.replace(/^--/g, '')) : effects;
|
|
116
116
|
}
|
|
117
|
-
const raw = this.dataset[
|
|
117
|
+
const raw = this.dataset[INTERACT_EFFECT_DATA_ATTR] || '';
|
|
118
118
|
const trimmed = raw.trim();
|
|
119
119
|
return trimmed ? trimmed.split(/\s+/) : [];
|
|
120
120
|
}
|
|
@@ -133,7 +133,7 @@ export function getWixInteractElement() {
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
_childListChangeHandler(listContainer, entries) {
|
|
136
|
-
const key = this.dataset.
|
|
136
|
+
const key = this.dataset.interactKey;
|
|
137
137
|
const removedElements = [];
|
|
138
138
|
const addedElements = [];
|
|
139
139
|
entries.forEach(entry => {
|
|
@@ -153,4 +153,4 @@ export function getWixInteractElement() {
|
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
//# sourceMappingURL=
|
|
156
|
+
//# sourceMappingURL=InteractElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["add","addListItems","remove","removeListItems","INTERACT_EFFECT_DATA_ATTR","getInteractElement","checkedForLegacyStateSyntax","isLegacyStateSyntax","InteractElement","HTMLElement","constructor","_defineProperty","connected","sheet","_observers","WeakMap","attachInternals","_internals","states","delete","e","connectedCallback","connect","disconnectedCallback","disconnect","key","dataset","interactKey","index","document","adoptedStyleSheets","indexOf","splice","console","warn","renderStyle","cssRules","CSSStyleSheet","replace","join","push","position","length","cssRule","insertRule","error","toggleEffect","effectId","method","item","has","clear","_this$dataset$INTERAC","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"],"sources":["../../src/InteractElement.ts"],"sourcesContent":["import type { StateParams } from './types';\nimport { add, addListItems } from './core/add';\nimport { remove, removeListItems } from './core/remove';\n\nexport const INTERACT_EFFECT_DATA_ATTR = 'interactEffect';\n\nexport function getInteractElement() {\n let checkedForLegacyStateSyntax = false;\n let isLegacyStateSyntax = false;\n\n return class InteractElement 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.interactKey;\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.interactKey;\n\n if (!key) {\n console.warn('InteractElement: 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(\n effectId: string,\n method: StateParams['method'],\n item?: HTMLElement | null,\n ) {\n if (item === null) {\n return;\n }\n if (isLegacyStateSyntax) {\n effectId = `--${effectId}`;\n }\n\n if (this._internals && !item) {\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[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 (item || this).dataset[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[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.interactKey;\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,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