@wix/interact 1.86.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/dist/cjs/__tests__/interact.spec.js +26 -0
- 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 +12 -0
- package/dist/cjs/core/Interact.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/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/esm/__tests__/interact.spec.js +25 -0
- 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 +12 -0
- package/dist/esm/core/Interact.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/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/types/__tests__/viewEnter.spec.d.ts +0 -0
- package/dist/types/core/Interact.d.ts +6 -1
- 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 +5 -0
- package/package.json +7 -6
package/dist/esm/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 '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};\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 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 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":[]}
|
|
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":[]}
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InteractCache, IInteractElement, InteractConfig, Effect, Interaction } from '../types';
|
|
1
|
+
import { InteractCache, IInteractElement, InteractConfig, Effect, Interaction, ViewEnterParams } from '../types';
|
|
2
2
|
export declare class Interact {
|
|
3
3
|
dataCache: InteractCache;
|
|
4
4
|
addedInteractions: {
|
|
@@ -23,6 +23,11 @@ export declare class Interact {
|
|
|
23
23
|
clearInteractionStateForKey(key: string): void;
|
|
24
24
|
static create(config: InteractConfig): Interact;
|
|
25
25
|
static destroy(): void;
|
|
26
|
+
static setup(options: {
|
|
27
|
+
scrollOptionsGetter?: () => Partial<scrollConfig>;
|
|
28
|
+
pointerOptionsGetter?: () => Partial<PointerConfig>;
|
|
29
|
+
viewEnter?: Partial<ViewEnterParams>;
|
|
30
|
+
}): void;
|
|
26
31
|
static getInstance(key: string): Interact | undefined;
|
|
27
32
|
static getElement(key: string | undefined): IInteractElement | undefined;
|
|
28
33
|
static setElement(key: string, element: IInteractElement): void;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { PointerMoveParams, ScrubEffect } from '../types';
|
|
2
|
+
declare function registerOptionsGetter(getter: () => Partial<PointerConfig>): void;
|
|
2
3
|
declare function addPointerMoveHandler(source: HTMLElement, target: HTMLElement, effect: ScrubEffect, options?: PointerMoveParams, reducedMotion?: boolean): void;
|
|
3
4
|
declare function removePointerMoveHandler(element: HTMLElement): void;
|
|
4
5
|
declare const _default: {
|
|
5
6
|
add: typeof addPointerMoveHandler;
|
|
6
7
|
remove: typeof removePointerMoveHandler;
|
|
8
|
+
registerOptionsGetter: typeof registerOptionsGetter;
|
|
7
9
|
};
|
|
8
10
|
export default _default;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { TimeEffect, ViewEnterParams } from '../types';
|
|
2
|
+
declare function setOptions(options: Partial<ViewEnterParams>): void;
|
|
2
3
|
declare function addViewEnterHandler(source: HTMLElement, target: HTMLElement, effect: TimeEffect, options?: ViewEnterParams, reducedMotion?: boolean): void;
|
|
3
4
|
declare function removeViewEnterHandler(element: HTMLElement): void;
|
|
4
5
|
declare const _default: {
|
|
5
6
|
add: typeof addViewEnterHandler;
|
|
6
7
|
remove: typeof removeViewEnterHandler;
|
|
8
|
+
setOptions: typeof setOptions;
|
|
7
9
|
};
|
|
8
10
|
export default _default;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ViewEnterParams, ScrubEffect } from '../types';
|
|
2
|
+
declare function registerOptionsGetter(getter: () => scrollConfig): void;
|
|
2
3
|
declare function addViewProgressHandler(source: HTMLElement, target: HTMLElement, effect: ScrubEffect, __: ViewEnterParams, reducedMotion?: boolean): void;
|
|
3
4
|
declare function removeViewProgressHandler(element: HTMLElement): void;
|
|
4
5
|
declare const _default: {
|
|
5
6
|
add: typeof addViewProgressHandler;
|
|
6
7
|
remove: typeof removeViewProgressHandler;
|
|
8
|
+
registerOptionsGetter: typeof registerOptionsGetter;
|
|
7
9
|
};
|
|
8
10
|
export default _default;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export type ViewEnterParams = {
|
|
|
22
22
|
type?: ViewEnterType;
|
|
23
23
|
threshold?: number;
|
|
24
24
|
inset?: string;
|
|
25
|
+
useSafeViewEnter?: boolean;
|
|
25
26
|
};
|
|
26
27
|
export type PointerMoveParams = {
|
|
27
28
|
hitArea?: 'root' | 'self';
|
|
@@ -144,9 +145,13 @@ export type InteractionParamsTypes = {
|
|
|
144
145
|
pointerMove: PointerMoveParams;
|
|
145
146
|
};
|
|
146
147
|
export type InteractionHandlerModule<T extends TriggerType> = {
|
|
148
|
+
registerOptionsGetter?: (getter: () => any) => void;
|
|
147
149
|
add: (source: HTMLElement, target: HTMLElement, effect: Effect, options: InteractionParamsTypes[T], reducedMotion?: boolean) => void;
|
|
148
150
|
remove: (element: HTMLElement) => void;
|
|
149
151
|
};
|
|
152
|
+
export type ViewEnterHandlerModule = InteractionHandlerModule<'viewEnter'> & {
|
|
153
|
+
setOptions: (options: Partial<ViewEnterParams>) => void;
|
|
154
|
+
};
|
|
150
155
|
export type TriggerHandlerMap<T extends TriggerType> = {
|
|
151
156
|
[K in T]: InteractionHandlerModule<K>;
|
|
152
157
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/interact",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.89.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "wow!Team",
|
|
6
6
|
"email": "wow-dev@wix.com"
|
|
@@ -32,16 +32,17 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.26.0",
|
|
35
|
-
"@wix/motion": "1.
|
|
35
|
+
"@wix/motion": "1.655.0",
|
|
36
|
+
"fastdom": "^1.0.12",
|
|
36
37
|
"fizban": "^0.7.0",
|
|
37
38
|
"kuliso": "^0.4.13"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@types/jest": "^27.5.2",
|
|
41
42
|
"@types/node": "^16.18.123",
|
|
42
|
-
"@wix/eslint-config-yoshi": "^6.
|
|
43
|
-
"@wix/jest-yoshi-preset": "^6.
|
|
44
|
-
"@wix/yoshi-flow-library": "^6.
|
|
43
|
+
"@wix/eslint-config-yoshi": "^6.163.0",
|
|
44
|
+
"@wix/jest-yoshi-preset": "^6.163.0",
|
|
45
|
+
"@wix/yoshi-flow-library": "^6.163.0",
|
|
45
46
|
"ts-jest": "^29.2.5",
|
|
46
47
|
"typescript": "~4.9.5"
|
|
47
48
|
},
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"wallaby": {
|
|
69
70
|
"autoDetect": true
|
|
70
71
|
},
|
|
71
|
-
"falconPackageHash": "
|
|
72
|
+
"falconPackageHash": "30a4b08c0940ff16d531c1707cd5c2523c58d09d75e91b9eec2f1630"
|
|
72
73
|
}
|