motion-dom 12.32.0 → 12.33.2
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/index.js +48 -12
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/gestures/press/index.mjs +6 -0
- package/dist/es/gestures/press/index.mjs.map +1 -1
- package/dist/es/projection/shared/stack.mjs +26 -12
- package/dist/es/projection/shared/stack.mjs.map +1 -1
- package/dist/es/render/utils/animation-state.mjs +16 -0
- package/dist/es/render/utils/animation-state.mjs.map +1 -1
- package/dist/index.d.ts +22 -1
- package/dist/motion-dom.dev.js +48 -12
- package/dist/motion-dom.js +1 -1
- package/package.json +2 -2
|
@@ -14,6 +14,7 @@ import { isPressing } from './utils/state.mjs';
|
|
|
14
14
|
function isValidPressEvent(event) {
|
|
15
15
|
return isPrimaryPointer(event) && !isDragActive();
|
|
16
16
|
}
|
|
17
|
+
const claimedPointerDownEvents = new WeakSet();
|
|
17
18
|
/**
|
|
18
19
|
* Create a press gesture.
|
|
19
20
|
*
|
|
@@ -39,7 +40,12 @@ function press(targetOrSelector, onPressStart, options = {}) {
|
|
|
39
40
|
const target = startEvent.currentTarget;
|
|
40
41
|
if (!isValidPressEvent(startEvent))
|
|
41
42
|
return;
|
|
43
|
+
if (claimedPointerDownEvents.has(startEvent))
|
|
44
|
+
return;
|
|
42
45
|
isPressing.add(target);
|
|
46
|
+
if (options.stopPropagation) {
|
|
47
|
+
claimedPointerDownEvents.add(startEvent);
|
|
48
|
+
}
|
|
43
49
|
const onPressEnd = onPressStart(target, startEvent);
|
|
44
50
|
const onPointerEnd = (endEvent, success) => {
|
|
45
51
|
window.removeEventListener("pointerup", onPointerUp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../../src/gestures/press/index.ts"],"sourcesContent":["import { isHTMLElement } from \"../../utils/is-html-element\"\nimport { ElementOrSelector } from \"../../utils/resolve-elements\"\nimport { isDragActive } from \"../drag/state/is-active\"\nimport { EventOptions } from \"../types\"\nimport { isNodeOrChild } from \"../utils/is-node-or-child\"\nimport { isPrimaryPointer } from \"../utils/is-primary-pointer\"\nimport { setupGesture } from \"../utils/setup\"\nimport { OnPressStartEvent } from \"./types\"\nimport { isElementKeyboardAccessible } from \"./utils/is-keyboard-accessible\"\nimport { enableKeyboardPress } from \"./utils/keyboard\"\nimport { isPressing } from \"./utils/state\"\n\n/**\n * Filter out events that are not primary pointer events, or are triggering\n * while a Motion gesture is active.\n */\nfunction isValidPressEvent(event: PointerEvent) {\n return isPrimaryPointer(event) && !isDragActive()\n}\n\nexport interface PointerEventOptions extends EventOptions {\n useGlobalTarget?: boolean\n}\n\n/**\n * Create a press gesture.\n *\n * Press is different to `\"pointerdown\"`, `\"pointerup\"` in that it\n * automatically filters out secondary pointer events like right\n * click and multitouch.\n *\n * It also adds accessibility support for keyboards, where\n * an element with a press gesture will receive focus and\n * trigger on Enter `\"keydown\"` and `\"keyup\"` events.\n *\n * This is different to a browser's `\"click\"` event, which does\n * respond to keyboards but only for the `\"click\"` itself, rather\n * than the press start and end/cancel. The element also needs\n * to be focusable for this to work, whereas a press gesture will\n * make an element focusable by default.\n *\n * @public\n */\nexport function press(\n targetOrSelector: ElementOrSelector,\n onPressStart: OnPressStartEvent,\n options: PointerEventOptions = {}\n): VoidFunction {\n const [targets, eventOptions, cancelEvents] = setupGesture(\n targetOrSelector,\n options\n )\n\n const startPress = (startEvent: PointerEvent) => {\n const target = startEvent.currentTarget as Element\n\n if (!isValidPressEvent(startEvent)) return\n\n isPressing.add(target)\n\n const onPressEnd = onPressStart(target, startEvent)\n\n const onPointerEnd = (endEvent: PointerEvent, success: boolean) => {\n window.removeEventListener(\"pointerup\", onPointerUp)\n window.removeEventListener(\"pointercancel\", onPointerCancel)\n\n if (isPressing.has(target)) {\n isPressing.delete(target)\n }\n\n if (!isValidPressEvent(endEvent)) {\n return\n }\n\n if (typeof onPressEnd === \"function\") {\n onPressEnd(endEvent, { success })\n }\n }\n\n const onPointerUp = (upEvent: PointerEvent) => {\n onPointerEnd(\n upEvent,\n (target as any) === window ||\n (target as any) === document ||\n options.useGlobalTarget ||\n isNodeOrChild(target, upEvent.target as Element)\n )\n }\n\n const onPointerCancel = (cancelEvent: PointerEvent) => {\n onPointerEnd(cancelEvent, false)\n }\n\n window.addEventListener(\"pointerup\", onPointerUp, eventOptions)\n window.addEventListener(\"pointercancel\", onPointerCancel, eventOptions)\n }\n\n targets.forEach((target: EventTarget) => {\n const pointerDownTarget = options.useGlobalTarget ? window : target\n pointerDownTarget.addEventListener(\n \"pointerdown\",\n startPress as EventListener,\n eventOptions\n )\n\n if (isHTMLElement(target)) {\n target.addEventListener(\"focus\", (event) =>\n enableKeyboardPress(event as FocusEvent, eventOptions)\n )\n\n if (\n !isElementKeyboardAccessible(target) &&\n !target.hasAttribute(\"tabindex\")\n ) {\n target.tabIndex = 0\n }\n }\n })\n\n return cancelEvents\n}\n"],"names":[],"mappings":";;;;;;;;;AAYA;;;AAGG;AACH,SAAS,iBAAiB,CAAC,KAAmB,EAAA;IAC1C,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAA;AACrD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../src/gestures/press/index.ts"],"sourcesContent":["import { isHTMLElement } from \"../../utils/is-html-element\"\nimport { ElementOrSelector } from \"../../utils/resolve-elements\"\nimport { isDragActive } from \"../drag/state/is-active\"\nimport { EventOptions } from \"../types\"\nimport { isNodeOrChild } from \"../utils/is-node-or-child\"\nimport { isPrimaryPointer } from \"../utils/is-primary-pointer\"\nimport { setupGesture } from \"../utils/setup\"\nimport { OnPressStartEvent } from \"./types\"\nimport { isElementKeyboardAccessible } from \"./utils/is-keyboard-accessible\"\nimport { enableKeyboardPress } from \"./utils/keyboard\"\nimport { isPressing } from \"./utils/state\"\n\n/**\n * Filter out events that are not primary pointer events, or are triggering\n * while a Motion gesture is active.\n */\nfunction isValidPressEvent(event: PointerEvent) {\n return isPrimaryPointer(event) && !isDragActive()\n}\n\nconst claimedPointerDownEvents = new WeakSet<Event>()\n\nexport interface PointerEventOptions extends EventOptions {\n useGlobalTarget?: boolean\n stopPropagation?: boolean\n}\n\n/**\n * Create a press gesture.\n *\n * Press is different to `\"pointerdown\"`, `\"pointerup\"` in that it\n * automatically filters out secondary pointer events like right\n * click and multitouch.\n *\n * It also adds accessibility support for keyboards, where\n * an element with a press gesture will receive focus and\n * trigger on Enter `\"keydown\"` and `\"keyup\"` events.\n *\n * This is different to a browser's `\"click\"` event, which does\n * respond to keyboards but only for the `\"click\"` itself, rather\n * than the press start and end/cancel. The element also needs\n * to be focusable for this to work, whereas a press gesture will\n * make an element focusable by default.\n *\n * @public\n */\nexport function press(\n targetOrSelector: ElementOrSelector,\n onPressStart: OnPressStartEvent,\n options: PointerEventOptions = {}\n): VoidFunction {\n const [targets, eventOptions, cancelEvents] = setupGesture(\n targetOrSelector,\n options\n )\n\n const startPress = (startEvent: PointerEvent) => {\n const target = startEvent.currentTarget as Element\n\n if (!isValidPressEvent(startEvent)) return\n if (claimedPointerDownEvents.has(startEvent)) return\n\n isPressing.add(target)\n\n if (options.stopPropagation) {\n claimedPointerDownEvents.add(startEvent)\n }\n\n const onPressEnd = onPressStart(target, startEvent)\n\n const onPointerEnd = (endEvent: PointerEvent, success: boolean) => {\n window.removeEventListener(\"pointerup\", onPointerUp)\n window.removeEventListener(\"pointercancel\", onPointerCancel)\n\n if (isPressing.has(target)) {\n isPressing.delete(target)\n }\n\n if (!isValidPressEvent(endEvent)) {\n return\n }\n\n if (typeof onPressEnd === \"function\") {\n onPressEnd(endEvent, { success })\n }\n }\n\n const onPointerUp = (upEvent: PointerEvent) => {\n onPointerEnd(\n upEvent,\n (target as any) === window ||\n (target as any) === document ||\n options.useGlobalTarget ||\n isNodeOrChild(target, upEvent.target as Element)\n )\n }\n\n const onPointerCancel = (cancelEvent: PointerEvent) => {\n onPointerEnd(cancelEvent, false)\n }\n\n window.addEventListener(\"pointerup\", onPointerUp, eventOptions)\n window.addEventListener(\"pointercancel\", onPointerCancel, eventOptions)\n }\n\n targets.forEach((target: EventTarget) => {\n const pointerDownTarget = options.useGlobalTarget ? window : target\n pointerDownTarget.addEventListener(\n \"pointerdown\",\n startPress as EventListener,\n eventOptions\n )\n\n if (isHTMLElement(target)) {\n target.addEventListener(\"focus\", (event) =>\n enableKeyboardPress(event as FocusEvent, eventOptions)\n )\n\n if (\n !isElementKeyboardAccessible(target) &&\n !target.hasAttribute(\"tabindex\")\n ) {\n target.tabIndex = 0\n }\n }\n })\n\n return cancelEvents\n}\n"],"names":[],"mappings":";;;;;;;;;AAYA;;;AAGG;AACH,SAAS,iBAAiB,CAAC,KAAmB,EAAA;IAC1C,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAA;AACrD,CAAC;AAED,MAAM,wBAAwB,GAAG,IAAI,OAAO,EAAS,CAAA;AAOrD;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,KAAK,CACjB,gBAAmC,EACnC,YAA+B,EAC/B,UAA+B,EAAE,EAAA;AAEjC,IAAA,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,GAAG,YAAY,CACtD,gBAAgB,EAChB,OAAO,CACV,CAAA;AAED,IAAA,MAAM,UAAU,GAAG,CAAC,UAAwB,KAAI;AAC5C,QAAA,MAAM,MAAM,GAAG,UAAU,CAAC,aAAwB,CAAA;AAElD,QAAA,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC;YAAE,OAAM;AAC1C,QAAA,IAAI,wBAAwB,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,OAAM;AAEpD,QAAA,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAEtB,QAAA,IAAI,OAAO,CAAC,eAAe,EAAE;AACzB,YAAA,wBAAwB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;SAC3C;QAED,MAAM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C,eAAe,GAAG,MAAM,GAAG,MAAM,CAAA;QACnE,iBAAiB,CAAC,gBAAgB,CAC9B,aAAa,EACb,UAA2B,EAC3B,YAAY,CACf,CAAA;AAED,QAAA,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;AACvB,YAAA,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,KACnC,mBAAmB,CAAC,KAAmB,EAAE,YAAY,CAAC,CACzD,CAAA;AAED,YAAA,IACI,CAAC,2BAA2B,CAAC,MAAM,CAAC;AACpC,gBAAA,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,EAClC;AACE,gBAAA,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAA;aACtB;SACJ;AACL,KAAC,CAAC,CAAA;AAEF,IAAA,OAAO,YAAY,CAAA;AACvB;;;;"}
|
|
@@ -6,6 +6,15 @@ class NodeStack {
|
|
|
6
6
|
}
|
|
7
7
|
add(node) {
|
|
8
8
|
addUniqueItem(this.members, node);
|
|
9
|
+
for (let i = this.members.length - 1; i >= 0; i--) {
|
|
10
|
+
const m = this.members[i];
|
|
11
|
+
if (m === node || m === this.lead || m === this.prevLead)
|
|
12
|
+
continue;
|
|
13
|
+
const inst = m.instance;
|
|
14
|
+
if (inst && inst.isConnected === false && m.isPresent !== false && !m.snapshot) {
|
|
15
|
+
removeItem(this.members, m);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
9
18
|
node.scheduleRender();
|
|
10
19
|
}
|
|
11
20
|
remove(node) {
|
|
@@ -30,7 +39,8 @@ class NodeStack {
|
|
|
30
39
|
let prevLead;
|
|
31
40
|
for (let i = indexOfNode; i >= 0; i--) {
|
|
32
41
|
const member = this.members[i];
|
|
33
|
-
|
|
42
|
+
const inst = member.instance;
|
|
43
|
+
if (member.isPresent !== false && (!inst || inst.isConnected !== false)) {
|
|
34
44
|
prevLead = member;
|
|
35
45
|
break;
|
|
36
46
|
}
|
|
@@ -65,17 +75,21 @@ class NodeStack {
|
|
|
65
75
|
nextDep !== undefined &&
|
|
66
76
|
prevDep === nextDep;
|
|
67
77
|
if (!dependencyMatches) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
const prevInstance = prevLead.instance;
|
|
79
|
+
const isStale = prevInstance && prevInstance.isConnected === false && !prevLead.snapshot;
|
|
80
|
+
if (!isStale) {
|
|
81
|
+
node.resumeFrom = prevLead;
|
|
82
|
+
if (preserveFollowOpacity) {
|
|
83
|
+
node.resumeFrom.preserveOpacity = true;
|
|
84
|
+
}
|
|
85
|
+
if (prevLead.snapshot) {
|
|
86
|
+
node.snapshot = prevLead.snapshot;
|
|
87
|
+
node.snapshot.latestValues =
|
|
88
|
+
prevLead.animationValues || prevLead.latestValues;
|
|
89
|
+
}
|
|
90
|
+
if (node.root && node.root.isUpdating) {
|
|
91
|
+
node.isLayoutDirty = true;
|
|
92
|
+
}
|
|
79
93
|
}
|
|
80
94
|
}
|
|
81
95
|
const { crossfade } = node.options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.mjs","sources":["../../../../src/projection/shared/stack.ts"],"sourcesContent":["import { addUniqueItem, removeItem } from \"motion-utils\"\nimport { IProjectionNode } from \"../node/types\"\n\nexport class NodeStack {\n lead?: IProjectionNode\n prevLead?: IProjectionNode\n members: IProjectionNode[] = []\n\n add(node: IProjectionNode) {\n addUniqueItem(this.members, node)\n node.scheduleRender()\n }\n\n remove(node: IProjectionNode) {\n removeItem(this.members, node)\n if (node === this.prevLead) {\n this.prevLead = undefined\n }\n if (node === this.lead) {\n const prevLead = this.members[this.members.length - 1]\n if (prevLead) {\n this.promote(prevLead)\n }\n }\n }\n\n relegate(node: IProjectionNode): boolean {\n const indexOfNode = this.members.findIndex((member) => node === member)\n if (indexOfNode === 0) return false\n\n /**\n * Find the next projection node that is present\n */\n let prevLead: IProjectionNode | undefined\n for (let i = indexOfNode; i >= 0; i--) {\n const member = this.members[i]\n if (member.isPresent !== false) {\n prevLead = member\n break\n }\n }\n\n if (prevLead) {\n this.promote(prevLead)\n return true\n } else {\n return false\n }\n }\n\n promote(node: IProjectionNode, preserveFollowOpacity?: boolean) {\n const prevLead = this.lead\n\n if (node === prevLead) return\n\n this.prevLead = prevLead\n this.lead = node\n\n node.show()\n\n if (prevLead) {\n prevLead.instance && prevLead.scheduleRender()\n node.scheduleRender()\n\n /**\n * If both the new and previous lead have the same defined layoutDependency,\n * skip the shared layout animation. This allows components with layoutId\n * to opt-out of animations when their layoutDependency hasn't changed,\n * even when the component unmounts and remounts in a different location.\n */\n const prevDep = prevLead.options.layoutDependency\n const nextDep = node.options.layoutDependency\n const dependencyMatches =\n prevDep !== undefined &&\n nextDep !== undefined &&\n prevDep === nextDep\n\n if (!dependencyMatches) {\n node.resumeFrom = prevLead\n\n
|
|
1
|
+
{"version":3,"file":"stack.mjs","sources":["../../../../src/projection/shared/stack.ts"],"sourcesContent":["import { addUniqueItem, removeItem } from \"motion-utils\"\nimport { IProjectionNode } from \"../node/types\"\n\nexport class NodeStack {\n lead?: IProjectionNode\n prevLead?: IProjectionNode\n members: IProjectionNode[] = []\n\n add(node: IProjectionNode) {\n addUniqueItem(this.members, node)\n\n for (let i = this.members.length - 1; i >= 0; i--) {\n const m = this.members[i]\n if (m === node || m === this.lead || m === this.prevLead) continue\n const inst = m.instance as HTMLElement | undefined\n if (inst && inst.isConnected === false && m.isPresent !== false && !m.snapshot) {\n removeItem(this.members, m)\n }\n }\n\n node.scheduleRender()\n }\n\n remove(node: IProjectionNode) {\n removeItem(this.members, node)\n if (node === this.prevLead) {\n this.prevLead = undefined\n }\n if (node === this.lead) {\n const prevLead = this.members[this.members.length - 1]\n if (prevLead) {\n this.promote(prevLead)\n }\n }\n }\n\n relegate(node: IProjectionNode): boolean {\n const indexOfNode = this.members.findIndex((member) => node === member)\n if (indexOfNode === 0) return false\n\n /**\n * Find the next projection node that is present\n */\n let prevLead: IProjectionNode | undefined\n for (let i = indexOfNode; i >= 0; i--) {\n const member = this.members[i]\n const inst = member.instance as HTMLElement | undefined\n if (member.isPresent !== false && (!inst || inst.isConnected !== false)) {\n prevLead = member\n break\n }\n }\n\n if (prevLead) {\n this.promote(prevLead)\n return true\n } else {\n return false\n }\n }\n\n promote(node: IProjectionNode, preserveFollowOpacity?: boolean) {\n const prevLead = this.lead\n\n if (node === prevLead) return\n\n this.prevLead = prevLead\n this.lead = node\n\n node.show()\n\n if (prevLead) {\n prevLead.instance && prevLead.scheduleRender()\n node.scheduleRender()\n\n /**\n * If both the new and previous lead have the same defined layoutDependency,\n * skip the shared layout animation. This allows components with layoutId\n * to opt-out of animations when their layoutDependency hasn't changed,\n * even when the component unmounts and remounts in a different location.\n */\n const prevDep = prevLead.options.layoutDependency\n const nextDep = node.options.layoutDependency\n const dependencyMatches =\n prevDep !== undefined &&\n nextDep !== undefined &&\n prevDep === nextDep\n\n if (!dependencyMatches) {\n const prevInstance = prevLead.instance as HTMLElement | undefined\n const isStale = prevInstance && prevInstance.isConnected === false && !prevLead.snapshot\n\n if (!isStale) {\n node.resumeFrom = prevLead\n\n if (preserveFollowOpacity) {\n node.resumeFrom.preserveOpacity = true\n }\n\n if (prevLead.snapshot) {\n node.snapshot = prevLead.snapshot\n node.snapshot.latestValues =\n prevLead.animationValues || prevLead.latestValues\n }\n\n if (node.root && node.root.isUpdating) {\n node.isLayoutDirty = true\n }\n }\n }\n\n const { crossfade } = node.options\n if (crossfade === false) {\n prevLead.hide()\n }\n }\n }\n\n exitAnimationComplete() {\n this.members.forEach((node) => {\n const { options, resumingFrom } = node\n\n options.onExitComplete && options.onExitComplete()\n\n if (resumingFrom) {\n resumingFrom.options.onExitComplete &&\n resumingFrom.options.onExitComplete()\n }\n })\n }\n\n scheduleRender() {\n this.members.forEach((node) => {\n node.instance && node.scheduleRender(false)\n })\n }\n\n /**\n * Clear any leads that have been removed this render to prevent them from being\n * used in future animations and to prevent memory leaks\n */\n removeLeadSnapshot() {\n if (this.lead && this.lead.snapshot) {\n this.lead.snapshot = undefined\n }\n }\n}\n"],"names":[],"mappings":";;MAGa,SAAS,CAAA;AAAtB,IAAA,WAAA,GAAA;QAGI,IAAO,CAAA,OAAA,GAAsB,EAAE,CAAA;KA4IlC;AA1IG,IAAA,GAAG,CAAC,IAAqB,EAAA;AACrB,QAAA,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AAEjC,QAAA,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;YAC/C,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;AACzB,YAAA,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,QAAQ;gBAAE,SAAQ;AAClE,YAAA,MAAM,IAAI,GAAG,CAAC,CAAC,QAAmC,CAAA;AAClD,YAAA,IAAI,IAAI,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,IAAI,CAAC,CAAC,SAAS,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE;AAC5E,gBAAA,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;aAC9B;SACJ;QAED,IAAI,CAAC,cAAc,EAAE,CAAA;KACxB;AAED,IAAA,MAAM,CAAC,IAAqB,EAAA;AACxB,QAAA,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AAC9B,QAAA,IAAI,IAAI,KAAK,IAAI,CAAC,QAAQ,EAAE;AACxB,YAAA,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;SAC5B;AACD,QAAA,IAAI,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;AACpB,YAA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,IAAI,CAAC,OAAO,CAAA;AAClC,YAAA,IAAI,SAAS,KAAK,KAAK,EAAE;gBACrB,QAAQ,CAAC,IAAI,EAAE,CAAA;aAClB;SACJ;KACJ;IAED,qBAAqB,GAAA;QACjB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AAC1B,YAAA,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;AAEtC,YAAA,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,cAAc,EAAE,CAAA;YAElD,IAAI,YAAY,EAAE;gBACd,YAAY,CAAC,OAAO,CAAC,cAAc;AAC/B,oBAAA,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;aAC5C;AACL,SAAC,CAAC,CAAA;KACL;IAED,cAAc,GAAA;QACV,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;YAC1B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;AAC/C,SAAC,CAAC,CAAA;KACL;AAED;;;AAGG;IACH,kBAAkB,GAAA;QACd,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;AACjC,YAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;SACjC;KACJ;AACJ;;;;"}
|
|
@@ -124,6 +124,22 @@ function createAnimationState(visualElement) {
|
|
|
124
124
|
typeof prop === "boolean") {
|
|
125
125
|
continue;
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* If exit is already active and wasn't just activated, skip
|
|
129
|
+
* re-processing to prevent interrupting running exit animations.
|
|
130
|
+
* Re-resolving exit with a changed custom value can start new
|
|
131
|
+
* value animations that stop the originals, leaving the exit
|
|
132
|
+
* animation promise unresolved and the component stuck in the DOM.
|
|
133
|
+
*/
|
|
134
|
+
if (type === "exit" && typeState.isActive && activeDelta !== true) {
|
|
135
|
+
if (typeState.prevResolvedValues) {
|
|
136
|
+
encounteredKeys = {
|
|
137
|
+
...encounteredKeys,
|
|
138
|
+
...typeState.prevResolvedValues,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
127
143
|
/**
|
|
128
144
|
* As we go look through the values defined on this type, if we detect
|
|
129
145
|
* a changed value or a value that was removed in a higher priority, we set
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animation-state.mjs","sources":["../../../../src/render/utils/animation-state.ts"],"sourcesContent":["import type {\n AnimationDefinition,\n TargetAndTransition,\n VariantLabels,\n} from \"../../node/types\"\nimport type { AnimationType } from \"../types\"\nimport type { VisualElementAnimationOptions } from \"../../animation/interfaces/types\"\nimport { animateVisualElement } from \"../../animation/interfaces/visual-element\"\nimport { calcChildStagger } from \"../../animation/utils/calc-child-stagger\"\nimport { getVariantContext } from \"./get-variant-context\"\nimport { isAnimationControls } from \"./is-animation-controls\"\nimport { isKeyframesTarget } from \"./is-keyframes-target\"\nimport { isVariantLabel } from \"./is-variant-label\"\nimport { resolveVariant } from \"./resolve-dynamic-variants\"\nimport { shallowCompare } from \"./shallow-compare\"\nimport { variantPriorityOrder } from \"./variant-props\"\n\nexport type { VisualElementAnimationOptions }\n\nexport interface AnimationState {\n animateChanges: (type?: AnimationType) => Promise<any>\n setActive: (\n type: AnimationType,\n isActive: boolean,\n options?: VisualElementAnimationOptions\n ) => Promise<any>\n setAnimateFunction: (fn: any) => void\n getState: () => { [key: string]: AnimationTypeState }\n reset: () => void\n}\n\ninterface DefinitionAndOptions {\n animation: AnimationDefinition\n options?: VisualElementAnimationOptions\n}\n\nexport type AnimationList = string[] | TargetAndTransition[]\n\nconst reversePriorityOrder = [...variantPriorityOrder].reverse()\nconst numAnimationTypes = variantPriorityOrder.length\n\n/**\n * Type for the animate function that can be injected.\n * This allows the animation implementation to be provided by the framework layer.\n */\nexport type AnimateFunction = (animations: DefinitionAndOptions[]) => Promise<any>\n\nfunction createAnimateFunction(visualElement: any): AnimateFunction {\n return (animations: DefinitionAndOptions[]) => {\n return Promise.all(\n animations.map(({ animation, options }) =>\n animateVisualElement(visualElement, animation, options)\n )\n )\n }\n}\n\nexport function createAnimationState(visualElement: any): AnimationState {\n let animate = createAnimateFunction(visualElement)\n let state = createState()\n let isInitialRender = true\n\n /**\n * This function will be used to reduce the animation definitions for\n * each active animation type into an object of resolved values for it.\n */\n const buildResolvedTypeValues =\n (type: AnimationType) =>\n (\n acc: { [key: string]: any },\n definition: string | TargetAndTransition | undefined\n ) => {\n const resolved = resolveVariant(\n visualElement,\n definition,\n type === \"exit\"\n ? visualElement.presenceContext?.custom\n : undefined\n )\n\n if (resolved) {\n const { transition, transitionEnd, ...target } = resolved\n acc = { ...acc, ...target, ...transitionEnd }\n }\n\n return acc\n }\n\n /**\n * This just allows us to inject mocked animation functions\n * @internal\n */\n function setAnimateFunction(\n makeAnimator: (visualElement: any) => AnimateFunction\n ) {\n animate = makeAnimator(visualElement)\n }\n\n /**\n * When we receive new props, we need to:\n * 1. Create a list of protected keys for each type. This is a directory of\n * value keys that are currently being \"handled\" by types of a higher priority\n * so that whenever an animation is played of a given type, these values are\n * protected from being animated.\n * 2. Determine if an animation type needs animating.\n * 3. Determine if any values have been removed from a type and figure out\n * what to animate those to.\n */\n function animateChanges(changedActiveType?: AnimationType) {\n const { props } = visualElement\n const context = getVariantContext(visualElement.parent) || {}\n\n /**\n * A list of animations that we'll build into as we iterate through the animation\n * types. This will get executed at the end of the function.\n */\n const animations: DefinitionAndOptions[] = []\n\n /**\n * Keep track of which values have been removed. Then, as we hit lower priority\n * animation types, we can check if they contain removed values and animate to that.\n */\n const removedKeys = new Set<string>()\n\n /**\n * A dictionary of all encountered keys. This is an object to let us build into and\n * copy it without iteration. Each time we hit an animation type we set its protected\n * keys - the keys its not allowed to animate - to the latest version of this object.\n */\n let encounteredKeys: { [key: string]: any } = {}\n\n /**\n * If a variant has been removed at a given index, and this component is controlling\n * variant animations, we want to ensure lower-priority variants are forced to animate.\n */\n let removedVariantIndex = Infinity\n\n /**\n * Iterate through all animation types in reverse priority order. For each, we want to\n * detect which values it's handling and whether or not they've changed (and therefore\n * need to be animated). If any values have been removed, we want to detect those in\n * lower priority props and flag for animation.\n */\n for (let i = 0; i < numAnimationTypes; i++) {\n const type = reversePriorityOrder[i]\n const typeState = state[type]\n const prop =\n props[type] !== undefined\n ? props[type]\n : context[type as keyof typeof context]\n const propIsVariant = isVariantLabel(prop)\n\n /**\n * If this type has *just* changed isActive status, set activeDelta\n * to that status. Otherwise set to null.\n */\n const activeDelta =\n type === changedActiveType ? typeState.isActive : null\n\n if (activeDelta === false) removedVariantIndex = i\n\n /**\n * If this prop is an inherited variant, rather than been set directly on the\n * component itself, we want to make sure we allow the parent to trigger animations.\n *\n * TODO: Can probably change this to a !isControllingVariants check\n */\n let isInherited =\n prop === context[type as keyof typeof context] &&\n prop !== props[type] &&\n propIsVariant\n\n if (\n isInherited &&\n isInitialRender &&\n visualElement.manuallyAnimateOnMount\n ) {\n isInherited = false\n }\n\n /**\n * Set all encountered keys so far as the protected keys for this type. This will\n * be any key that has been animated or otherwise handled by active, higher-priortiy types.\n */\n typeState.protectedKeys = { ...encounteredKeys }\n\n // Check if we can skip analysing this prop early\n if (\n // If it isn't active and hasn't *just* been set as inactive\n (!typeState.isActive && activeDelta === null) ||\n // If we didn't and don't have any defined prop for this animation type\n (!prop && !typeState.prevProp) ||\n // Or if the prop doesn't define an animation\n isAnimationControls(prop) ||\n typeof prop === \"boolean\"\n ) {\n continue\n }\n\n /**\n * As we go look through the values defined on this type, if we detect\n * a changed value or a value that was removed in a higher priority, we set\n * this to true and add this prop to the animation list.\n */\n const variantDidChange = checkVariantsDidChange(\n typeState.prevProp,\n prop\n )\n\n let shouldAnimateType =\n variantDidChange ||\n // If we're making this variant active, we want to always make it active\n (type === changedActiveType &&\n typeState.isActive &&\n !isInherited &&\n propIsVariant) ||\n // If we removed a higher-priority variant (i is in reverse order)\n (i > removedVariantIndex && propIsVariant)\n\n let handledRemovedValues = false\n\n /**\n * As animations can be set as variant lists, variants or target objects, we\n * coerce everything to an array if it isn't one already\n */\n const definitionList = Array.isArray(prop) ? prop : [prop]\n\n /**\n * Build an object of all the resolved values. We'll use this in the subsequent\n * animateChanges calls to determine whether a value has changed.\n */\n let resolvedValues = definitionList.reduce(\n buildResolvedTypeValues(type),\n {}\n )\n\n if (activeDelta === false) resolvedValues = {}\n\n /**\n * Now we need to loop through all the keys in the prev prop and this prop,\n * and decide:\n * 1. If the value has changed, and needs animating\n * 2. If it has been removed, and needs adding to the removedKeys set\n * 3. If it has been removed in a higher priority type and needs animating\n * 4. If it hasn't been removed in a higher priority but hasn't changed, and\n * needs adding to the type's protectedKeys list.\n */\n const { prevResolvedValues = {} } = typeState\n\n const allKeys = {\n ...prevResolvedValues,\n ...resolvedValues,\n }\n const markToAnimate = (key: string) => {\n shouldAnimateType = true\n if (removedKeys.has(key)) {\n handledRemovedValues = true\n removedKeys.delete(key)\n }\n typeState.needsAnimating[key] = true\n\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = false\n }\n\n for (const key in allKeys) {\n const next = resolvedValues[key]\n const prev = prevResolvedValues[key]\n\n // If we've already handled this we can just skip ahead\n if (encounteredKeys.hasOwnProperty(key)) continue\n\n /**\n * If the value has changed, we probably want to animate it.\n */\n let valueHasChanged = false\n if (isKeyframesTarget(next) && isKeyframesTarget(prev)) {\n valueHasChanged = !shallowCompare(next, prev)\n } else {\n valueHasChanged = next !== prev\n }\n\n if (valueHasChanged) {\n if (next !== undefined && next !== null) {\n // If next is defined and doesn't equal prev, it needs animating\n markToAnimate(key)\n } else {\n // If it's undefined, it's been removed.\n removedKeys.add(key)\n }\n } else if (next !== undefined && removedKeys.has(key)) {\n /**\n * If next hasn't changed and it isn't undefined, we want to check if it's\n * been removed by a higher priority\n */\n markToAnimate(key)\n } else {\n /**\n * If it hasn't changed, we add it to the list of protected values\n * to ensure it doesn't get animated.\n */\n typeState.protectedKeys[key] = true\n }\n }\n\n /**\n * Update the typeState so next time animateChanges is called we can compare the\n * latest prop and resolvedValues to these.\n */\n typeState.prevProp = prop\n typeState.prevResolvedValues = resolvedValues\n\n if (typeState.isActive) {\n encounteredKeys = { ...encounteredKeys, ...resolvedValues }\n }\n\n if (isInitialRender && visualElement.blockInitialAnimation) {\n shouldAnimateType = false\n }\n\n /**\n * If this is an inherited prop we want to skip this animation\n * unless the inherited variants haven't changed on this render.\n */\n const willAnimateViaParent = isInherited && variantDidChange\n const needsAnimating = !willAnimateViaParent || handledRemovedValues\n if (shouldAnimateType && needsAnimating) {\n animations.push(\n ...definitionList.map((animation) => {\n const options: VisualElementAnimationOptions = { type }\n\n /**\n * If we're performing the initial animation, but we're not\n * rendering at the same time as the variant-controlling parent,\n * we want to use the parent's transition to calculate the stagger.\n */\n if (\n typeof animation === \"string\" &&\n isInitialRender &&\n !willAnimateViaParent &&\n visualElement.manuallyAnimateOnMount &&\n visualElement.parent\n ) {\n const { parent } = visualElement\n const parentVariant = resolveVariant(\n parent,\n animation\n )\n\n if (parent.enteringChildren && parentVariant) {\n const { delayChildren } =\n parentVariant.transition || {}\n options.delay = calcChildStagger(\n parent.enteringChildren,\n visualElement,\n delayChildren\n )\n }\n }\n\n return {\n animation: animation as AnimationDefinition,\n options,\n }\n })\n )\n }\n }\n\n /**\n * If there are some removed value that haven't been dealt with,\n * we need to create a new animation that falls back either to the value\n * defined in the style prop, or the last read value.\n */\n if (removedKeys.size) {\n const fallbackAnimation: TargetAndTransition = {}\n\n /**\n * If the initial prop contains a transition we can use that, otherwise\n * allow the animation function to use the visual element's default.\n */\n if (typeof props.initial !== \"boolean\") {\n const initialTransition = resolveVariant(\n visualElement,\n Array.isArray(props.initial)\n ? props.initial[0]\n : props.initial\n )\n\n if (initialTransition && initialTransition.transition) {\n fallbackAnimation.transition = initialTransition.transition\n }\n }\n\n removedKeys.forEach((key) => {\n const fallbackTarget = visualElement.getBaseTarget(key)\n\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = true\n\n // @ts-expect-error - @mattgperry to figure if we should do something here\n fallbackAnimation[key] = fallbackTarget ?? null\n })\n\n animations.push({ animation: fallbackAnimation })\n }\n\n let shouldAnimate = Boolean(animations.length)\n\n if (\n isInitialRender &&\n (props.initial === false || props.initial === props.animate) &&\n !visualElement.manuallyAnimateOnMount\n ) {\n shouldAnimate = false\n }\n\n isInitialRender = false\n return shouldAnimate ? animate(animations) : Promise.resolve()\n }\n\n /**\n * Change whether a certain animation type is active.\n */\n function setActive(type: AnimationType, isActive: boolean) {\n // If the active state hasn't changed, we can safely do nothing here\n if (state[type].isActive === isActive) return Promise.resolve()\n\n // Propagate active change to children\n visualElement.variantChildren?.forEach((child: any) =>\n child.animationState?.setActive(type, isActive)\n )\n\n state[type].isActive = isActive\n\n const animations = animateChanges(type)\n\n for (const key in state) {\n state[key as keyof typeof state].protectedKeys = {}\n }\n\n return animations\n }\n\n return {\n animateChanges,\n setActive,\n setAnimateFunction,\n getState: () => state,\n reset: () => {\n state = createState()\n /**\n * Temporarily disabling resetting this flag as it prevents components\n * with initial={false} from animating after being remounted, for instance\n * as the child of an Activity component.\n */\n // isInitialRender = true\n },\n }\n}\n\nexport function checkVariantsDidChange(prev: any, next: any) {\n if (typeof next === \"string\") {\n return next !== prev\n } else if (Array.isArray(next)) {\n return !shallowCompare(next, prev)\n }\n\n return false\n}\n\nexport interface AnimationTypeState {\n isActive: boolean\n protectedKeys: { [key: string]: true }\n needsAnimating: { [key: string]: boolean }\n prevResolvedValues: { [key: string]: any }\n prevProp?: VariantLabels | TargetAndTransition\n}\n\nfunction createTypeState(isActive = false): AnimationTypeState {\n return {\n isActive,\n protectedKeys: {},\n needsAnimating: {},\n prevResolvedValues: {},\n }\n}\n\nfunction createState() {\n return {\n animate: createTypeState(true),\n whileInView: createTypeState(),\n whileHover: createTypeState(),\n whileTap: createTypeState(),\n whileDrag: createTypeState(),\n whileFocus: createTypeState(),\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,OAAO,IAAI,KAAK,IAAI,CAAA;KACvB;AAAM,SAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AAC5B,QAAA,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;KACrC;AAED,IAAA,OAAO,KAAK,CAAA;AAChB,CAAC;AAUD,SAAS,eAAe,CAAC,QAAQ,GAAG,KAAK,EAAA;IACrC,OAAO;QACH,QAAQ;AACR,QAAA,aAAa,EAAE,EAAE;AACjB,QAAA,cAAc,EAAE,EAAE;AAClB,QAAA,kBAAkB,EAAE,EAAE;KACzB,CAAA;AACL,CAAC;AAED,SAAS,WAAW,GAAA;IAChB,OAAO;AACH,QAAA,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC;QAC9B,WAAW,EAAE,eAAe,EAAE;QAC9B,UAAU,EAAE,eAAe,EAAE;QAC7B,QAAQ,EAAE,eAAe,EAAE;QAC3B,SAAS,EAAE,eAAe,EAAE;QAC5B,UAAU,EAAE,eAAe,EAAE;QAC7B,IAAI,EAAE,eAAe,EAAE;KAC1B,CAAA;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"animation-state.mjs","sources":["../../../../src/render/utils/animation-state.ts"],"sourcesContent":["import type {\n AnimationDefinition,\n TargetAndTransition,\n VariantLabels,\n} from \"../../node/types\"\nimport type { AnimationType } from \"../types\"\nimport type { VisualElementAnimationOptions } from \"../../animation/interfaces/types\"\nimport { animateVisualElement } from \"../../animation/interfaces/visual-element\"\nimport { calcChildStagger } from \"../../animation/utils/calc-child-stagger\"\nimport { getVariantContext } from \"./get-variant-context\"\nimport { isAnimationControls } from \"./is-animation-controls\"\nimport { isKeyframesTarget } from \"./is-keyframes-target\"\nimport { isVariantLabel } from \"./is-variant-label\"\nimport { resolveVariant } from \"./resolve-dynamic-variants\"\nimport { shallowCompare } from \"./shallow-compare\"\nimport { variantPriorityOrder } from \"./variant-props\"\n\nexport type { VisualElementAnimationOptions }\n\nexport interface AnimationState {\n animateChanges: (type?: AnimationType) => Promise<any>\n setActive: (\n type: AnimationType,\n isActive: boolean,\n options?: VisualElementAnimationOptions\n ) => Promise<any>\n setAnimateFunction: (fn: any) => void\n getState: () => { [key: string]: AnimationTypeState }\n reset: () => void\n}\n\ninterface DefinitionAndOptions {\n animation: AnimationDefinition\n options?: VisualElementAnimationOptions\n}\n\nexport type AnimationList = string[] | TargetAndTransition[]\n\nconst reversePriorityOrder = [...variantPriorityOrder].reverse()\nconst numAnimationTypes = variantPriorityOrder.length\n\n/**\n * Type for the animate function that can be injected.\n * This allows the animation implementation to be provided by the framework layer.\n */\nexport type AnimateFunction = (animations: DefinitionAndOptions[]) => Promise<any>\n\nfunction createAnimateFunction(visualElement: any): AnimateFunction {\n return (animations: DefinitionAndOptions[]) => {\n return Promise.all(\n animations.map(({ animation, options }) =>\n animateVisualElement(visualElement, animation, options)\n )\n )\n }\n}\n\nexport function createAnimationState(visualElement: any): AnimationState {\n let animate = createAnimateFunction(visualElement)\n let state = createState()\n let isInitialRender = true\n\n /**\n * This function will be used to reduce the animation definitions for\n * each active animation type into an object of resolved values for it.\n */\n const buildResolvedTypeValues =\n (type: AnimationType) =>\n (\n acc: { [key: string]: any },\n definition: string | TargetAndTransition | undefined\n ) => {\n const resolved = resolveVariant(\n visualElement,\n definition,\n type === \"exit\"\n ? visualElement.presenceContext?.custom\n : undefined\n )\n\n if (resolved) {\n const { transition, transitionEnd, ...target } = resolved\n acc = { ...acc, ...target, ...transitionEnd }\n }\n\n return acc\n }\n\n /**\n * This just allows us to inject mocked animation functions\n * @internal\n */\n function setAnimateFunction(\n makeAnimator: (visualElement: any) => AnimateFunction\n ) {\n animate = makeAnimator(visualElement)\n }\n\n /**\n * When we receive new props, we need to:\n * 1. Create a list of protected keys for each type. This is a directory of\n * value keys that are currently being \"handled\" by types of a higher priority\n * so that whenever an animation is played of a given type, these values are\n * protected from being animated.\n * 2. Determine if an animation type needs animating.\n * 3. Determine if any values have been removed from a type and figure out\n * what to animate those to.\n */\n function animateChanges(changedActiveType?: AnimationType) {\n const { props } = visualElement\n const context = getVariantContext(visualElement.parent) || {}\n\n /**\n * A list of animations that we'll build into as we iterate through the animation\n * types. This will get executed at the end of the function.\n */\n const animations: DefinitionAndOptions[] = []\n\n /**\n * Keep track of which values have been removed. Then, as we hit lower priority\n * animation types, we can check if they contain removed values and animate to that.\n */\n const removedKeys = new Set<string>()\n\n /**\n * A dictionary of all encountered keys. This is an object to let us build into and\n * copy it without iteration. Each time we hit an animation type we set its protected\n * keys - the keys its not allowed to animate - to the latest version of this object.\n */\n let encounteredKeys: { [key: string]: any } = {}\n\n /**\n * If a variant has been removed at a given index, and this component is controlling\n * variant animations, we want to ensure lower-priority variants are forced to animate.\n */\n let removedVariantIndex = Infinity\n\n /**\n * Iterate through all animation types in reverse priority order. For each, we want to\n * detect which values it's handling and whether or not they've changed (and therefore\n * need to be animated). If any values have been removed, we want to detect those in\n * lower priority props and flag for animation.\n */\n for (let i = 0; i < numAnimationTypes; i++) {\n const type = reversePriorityOrder[i]\n const typeState = state[type]\n const prop =\n props[type] !== undefined\n ? props[type]\n : context[type as keyof typeof context]\n const propIsVariant = isVariantLabel(prop)\n\n /**\n * If this type has *just* changed isActive status, set activeDelta\n * to that status. Otherwise set to null.\n */\n const activeDelta =\n type === changedActiveType ? typeState.isActive : null\n\n if (activeDelta === false) removedVariantIndex = i\n\n /**\n * If this prop is an inherited variant, rather than been set directly on the\n * component itself, we want to make sure we allow the parent to trigger animations.\n *\n * TODO: Can probably change this to a !isControllingVariants check\n */\n let isInherited =\n prop === context[type as keyof typeof context] &&\n prop !== props[type] &&\n propIsVariant\n\n if (\n isInherited &&\n isInitialRender &&\n visualElement.manuallyAnimateOnMount\n ) {\n isInherited = false\n }\n\n /**\n * Set all encountered keys so far as the protected keys for this type. This will\n * be any key that has been animated or otherwise handled by active, higher-priortiy types.\n */\n typeState.protectedKeys = { ...encounteredKeys }\n\n // Check if we can skip analysing this prop early\n if (\n // If it isn't active and hasn't *just* been set as inactive\n (!typeState.isActive && activeDelta === null) ||\n // If we didn't and don't have any defined prop for this animation type\n (!prop && !typeState.prevProp) ||\n // Or if the prop doesn't define an animation\n isAnimationControls(prop) ||\n typeof prop === \"boolean\"\n ) {\n continue\n }\n\n /**\n * If exit is already active and wasn't just activated, skip\n * re-processing to prevent interrupting running exit animations.\n * Re-resolving exit with a changed custom value can start new\n * value animations that stop the originals, leaving the exit\n * animation promise unresolved and the component stuck in the DOM.\n */\n if (type === \"exit\" && typeState.isActive && activeDelta !== true) {\n if (typeState.prevResolvedValues) {\n encounteredKeys = {\n ...encounteredKeys,\n ...typeState.prevResolvedValues,\n }\n }\n continue\n }\n\n /**\n * As we go look through the values defined on this type, if we detect\n * a changed value or a value that was removed in a higher priority, we set\n * this to true and add this prop to the animation list.\n */\n const variantDidChange = checkVariantsDidChange(\n typeState.prevProp,\n prop\n )\n\n let shouldAnimateType =\n variantDidChange ||\n // If we're making this variant active, we want to always make it active\n (type === changedActiveType &&\n typeState.isActive &&\n !isInherited &&\n propIsVariant) ||\n // If we removed a higher-priority variant (i is in reverse order)\n (i > removedVariantIndex && propIsVariant)\n\n let handledRemovedValues = false\n\n /**\n * As animations can be set as variant lists, variants or target objects, we\n * coerce everything to an array if it isn't one already\n */\n const definitionList = Array.isArray(prop) ? prop : [prop]\n\n /**\n * Build an object of all the resolved values. We'll use this in the subsequent\n * animateChanges calls to determine whether a value has changed.\n */\n let resolvedValues = definitionList.reduce(\n buildResolvedTypeValues(type),\n {}\n )\n\n if (activeDelta === false) resolvedValues = {}\n\n /**\n * Now we need to loop through all the keys in the prev prop and this prop,\n * and decide:\n * 1. If the value has changed, and needs animating\n * 2. If it has been removed, and needs adding to the removedKeys set\n * 3. If it has been removed in a higher priority type and needs animating\n * 4. If it hasn't been removed in a higher priority but hasn't changed, and\n * needs adding to the type's protectedKeys list.\n */\n const { prevResolvedValues = {} } = typeState\n\n const allKeys = {\n ...prevResolvedValues,\n ...resolvedValues,\n }\n const markToAnimate = (key: string) => {\n shouldAnimateType = true\n if (removedKeys.has(key)) {\n handledRemovedValues = true\n removedKeys.delete(key)\n }\n typeState.needsAnimating[key] = true\n\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = false\n }\n\n for (const key in allKeys) {\n const next = resolvedValues[key]\n const prev = prevResolvedValues[key]\n\n // If we've already handled this we can just skip ahead\n if (encounteredKeys.hasOwnProperty(key)) continue\n\n /**\n * If the value has changed, we probably want to animate it.\n */\n let valueHasChanged = false\n if (isKeyframesTarget(next) && isKeyframesTarget(prev)) {\n valueHasChanged = !shallowCompare(next, prev)\n } else {\n valueHasChanged = next !== prev\n }\n\n if (valueHasChanged) {\n if (next !== undefined && next !== null) {\n // If next is defined and doesn't equal prev, it needs animating\n markToAnimate(key)\n } else {\n // If it's undefined, it's been removed.\n removedKeys.add(key)\n }\n } else if (next !== undefined && removedKeys.has(key)) {\n /**\n * If next hasn't changed and it isn't undefined, we want to check if it's\n * been removed by a higher priority\n */\n markToAnimate(key)\n } else {\n /**\n * If it hasn't changed, we add it to the list of protected values\n * to ensure it doesn't get animated.\n */\n typeState.protectedKeys[key] = true\n }\n }\n\n /**\n * Update the typeState so next time animateChanges is called we can compare the\n * latest prop and resolvedValues to these.\n */\n typeState.prevProp = prop\n typeState.prevResolvedValues = resolvedValues\n\n if (typeState.isActive) {\n encounteredKeys = { ...encounteredKeys, ...resolvedValues }\n }\n\n if (isInitialRender && visualElement.blockInitialAnimation) {\n shouldAnimateType = false\n }\n\n /**\n * If this is an inherited prop we want to skip this animation\n * unless the inherited variants haven't changed on this render.\n */\n const willAnimateViaParent = isInherited && variantDidChange\n const needsAnimating = !willAnimateViaParent || handledRemovedValues\n if (shouldAnimateType && needsAnimating) {\n animations.push(\n ...definitionList.map((animation) => {\n const options: VisualElementAnimationOptions = { type }\n\n /**\n * If we're performing the initial animation, but we're not\n * rendering at the same time as the variant-controlling parent,\n * we want to use the parent's transition to calculate the stagger.\n */\n if (\n typeof animation === \"string\" &&\n isInitialRender &&\n !willAnimateViaParent &&\n visualElement.manuallyAnimateOnMount &&\n visualElement.parent\n ) {\n const { parent } = visualElement\n const parentVariant = resolveVariant(\n parent,\n animation\n )\n\n if (parent.enteringChildren && parentVariant) {\n const { delayChildren } =\n parentVariant.transition || {}\n options.delay = calcChildStagger(\n parent.enteringChildren,\n visualElement,\n delayChildren\n )\n }\n }\n\n return {\n animation: animation as AnimationDefinition,\n options,\n }\n })\n )\n }\n }\n\n /**\n * If there are some removed value that haven't been dealt with,\n * we need to create a new animation that falls back either to the value\n * defined in the style prop, or the last read value.\n */\n if (removedKeys.size) {\n const fallbackAnimation: TargetAndTransition = {}\n\n /**\n * If the initial prop contains a transition we can use that, otherwise\n * allow the animation function to use the visual element's default.\n */\n if (typeof props.initial !== \"boolean\") {\n const initialTransition = resolveVariant(\n visualElement,\n Array.isArray(props.initial)\n ? props.initial[0]\n : props.initial\n )\n\n if (initialTransition && initialTransition.transition) {\n fallbackAnimation.transition = initialTransition.transition\n }\n }\n\n removedKeys.forEach((key) => {\n const fallbackTarget = visualElement.getBaseTarget(key)\n\n const motionValue = visualElement.getValue(key)\n if (motionValue) motionValue.liveStyle = true\n\n // @ts-expect-error - @mattgperry to figure if we should do something here\n fallbackAnimation[key] = fallbackTarget ?? null\n })\n\n animations.push({ animation: fallbackAnimation })\n }\n\n let shouldAnimate = Boolean(animations.length)\n\n if (\n isInitialRender &&\n (props.initial === false || props.initial === props.animate) &&\n !visualElement.manuallyAnimateOnMount\n ) {\n shouldAnimate = false\n }\n\n isInitialRender = false\n return shouldAnimate ? animate(animations) : Promise.resolve()\n }\n\n /**\n * Change whether a certain animation type is active.\n */\n function setActive(type: AnimationType, isActive: boolean) {\n // If the active state hasn't changed, we can safely do nothing here\n if (state[type].isActive === isActive) return Promise.resolve()\n\n // Propagate active change to children\n visualElement.variantChildren?.forEach((child: any) =>\n child.animationState?.setActive(type, isActive)\n )\n\n state[type].isActive = isActive\n\n const animations = animateChanges(type)\n\n for (const key in state) {\n state[key as keyof typeof state].protectedKeys = {}\n }\n\n return animations\n }\n\n return {\n animateChanges,\n setActive,\n setAnimateFunction,\n getState: () => state,\n reset: () => {\n state = createState()\n /**\n * Temporarily disabling resetting this flag as it prevents components\n * with initial={false} from animating after being remounted, for instance\n * as the child of an Activity component.\n */\n // isInitialRender = true\n },\n }\n}\n\nexport function checkVariantsDidChange(prev: any, next: any) {\n if (typeof next === \"string\") {\n return next !== prev\n } else if (Array.isArray(next)) {\n return !shallowCompare(next, prev)\n }\n\n return false\n}\n\nexport interface AnimationTypeState {\n isActive: boolean\n protectedKeys: { [key: string]: true }\n needsAnimating: { [key: string]: boolean }\n prevResolvedValues: { [key: string]: any }\n prevProp?: VariantLabels | TargetAndTransition\n}\n\nfunction createTypeState(isActive = false): AnimationTypeState {\n return {\n isActive,\n protectedKeys: {},\n needsAnimating: {},\n prevResolvedValues: {},\n }\n}\n\nfunction createState() {\n return {\n animate: createTypeState(true),\n whileInView: createTypeState(),\n whileHover: createTypeState(),\n whileTap: createTypeState(),\n whileDrag: createTypeState(),\n whileFocus: createTypeState(),\n exit: createTypeState(),\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAsCA,MAAM,oBAAoB,GAAG,CAAC,GAAG,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAA;AAChE,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,MAAM,CAAA;AAQrD,SAAS,qBAAqB,CAAC,aAAkB,EAAA;IAC7C,OAAO,CAAC,UAAkC,KAAI;QAC1C,OAAO,OAAO,CAAC,GAAG,CACd,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,KAClC,oBAAoB,CAAC,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,CAC1D,CACJ,CAAA;AACL,KAAC,CAAA;AACL,CAAC;AAEK,SAAU,oBAAoB,CAAC,aAAkB,EAAA;AACnD,IAAA,IAAI,OAAO,GAAG,qBAAqB,CAAC,aAAa,CAAC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;QACH,QAAQ;AACR,QAAA,aAAa,EAAE,EAAE;AACjB,QAAA,cAAc,EAAE,EAAE;AAClB,QAAA,kBAAkB,EAAE,EAAE;KACzB,CAAA;AACL,CAAC;AAED,SAAS,WAAW,GAAA;IAChB,OAAO;AACH,QAAA,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC;QAC9B,WAAW,EAAE,eAAe,EAAE;QAC9B,UAAU,EAAE,eAAe,EAAE;QAC7B,QAAQ,EAAE,eAAe,EAAE;QAC3B,SAAS,EAAE,eAAe,EAAE;QAC5B,UAAU,EAAE,eAAe,EAAE;QAC7B,IAAI,EAAE,eAAe,EAAE;KAC1B,CAAA;AACL;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1018,7 +1018,27 @@ interface MotionNodeAdvancedOptions {
|
|
|
1018
1018
|
transformTemplate?: TransformTemplate;
|
|
1019
1019
|
"data-framer-appear-id"?: string;
|
|
1020
1020
|
}
|
|
1021
|
+
interface PropagateOptions {
|
|
1022
|
+
/**
|
|
1023
|
+
* If `false`, this element's tap gesture will prevent any parent
|
|
1024
|
+
* element's tap gesture handlers (`onTap`, `onTapStart`, `whileTap`)
|
|
1025
|
+
* from firing. Defaults to `true`.
|
|
1026
|
+
*/
|
|
1027
|
+
tap?: boolean;
|
|
1028
|
+
}
|
|
1021
1029
|
interface MotionNodeOptions extends MotionNodeAnimationOptions, MotionNodeEventOptions, MotionNodePanHandlers, MotionNodeTapHandlers, MotionNodeHoverHandlers, MotionNodeFocusHandlers, MotionNodeViewportOptions, MotionNodeDragHandlers, MotionNodeDraggableOptions, MotionNodeLayoutOptions, MotionNodeAdvancedOptions {
|
|
1030
|
+
/**
|
|
1031
|
+
* Controls whether gesture events propagate to parent motion components.
|
|
1032
|
+
* By default all gestures propagate. Set individual gestures to `false`
|
|
1033
|
+
* to prevent parent handlers from firing.
|
|
1034
|
+
*
|
|
1035
|
+
* ```jsx
|
|
1036
|
+
* <motion.div onTap={onParentTap}>
|
|
1037
|
+
* <motion.div onTap={onChildTap} propagate={{ tap: false }} />
|
|
1038
|
+
* </motion.div>
|
|
1039
|
+
* ```
|
|
1040
|
+
*/
|
|
1041
|
+
propagate?: PropagateOptions;
|
|
1022
1042
|
}
|
|
1023
1043
|
|
|
1024
1044
|
/**
|
|
@@ -3101,6 +3121,7 @@ type OnPressStartEvent = (element: Element, event: PointerEvent) => OnPressEndEv
|
|
|
3101
3121
|
|
|
3102
3122
|
interface PointerEventOptions extends EventOptions {
|
|
3103
3123
|
useGlobalTarget?: boolean;
|
|
3124
|
+
stopPropagation?: boolean;
|
|
3104
3125
|
}
|
|
3105
3126
|
/**
|
|
3106
3127
|
* Create a press gesture.
|
|
@@ -5027,4 +5048,4 @@ declare const sync: Batcher;
|
|
|
5027
5048
|
*/
|
|
5028
5049
|
declare const cancelSync: Record<string, (process: Process) => void>;
|
|
5029
5050
|
|
|
5030
|
-
export { type AcceptedAnimations, type ActiveStatsBuffer, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationList, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState, type AnimationType, type AnimationTypeState, type AnyResolvedKeyframe, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, DOMVisualElement, type DOMVisualElementOptions, type DecayOptions, type DelayedFunction, DocumentProjectionNode, type DragElastic, type DragHandler, type DraggableProps, type DurationSpringOptions, type DynamicOption, type ElementOrSelector, type EventInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type FrameStats, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, HTMLProjectionNode, type HTMLRenderState, HTMLVisualElement, type HandoffFunction, type IProjectionNode, type InactiveStatsBuffer, type InertiaOptions, type InitialPromotionConfig, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, LayoutAnimationBuilder, type LayoutEvents, type LayoutLifecycles, type LayoutUpdateData, type LayoutUpdateHandler, type LegacyAnimationControls, type MapInputRange, type Measurements, type Mixer, type MixerFactory, type MotionConfigContextProps, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, type MotionStyle, MotionValue, type MotionValueEventCallbacks, type MotionValueOptions, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NodeGroup, NodeStack, type NumberMap, ObjectVisualElement, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, type PassiveEffect, type Phase, type PointerEventOptions, type PresenceContextProps, type PressGestureInfo, type Process, type ProgressTimeline, type ProjectionEventName, type ProjectionNodeConfig, type ProjectionNodeOptions, type RGBA, type ReducedMotionConfig, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues$1 as ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGRenderState, type SVGTransitions, SVGVisualElement, type ScaleCorrectionNode, type ScaleCorrector, type ScaleCorrectorDefinition, type ScaleCorrectorMap, type Schedule, type ScrapeMotionValuesFromProps, type ScrollMeasurements, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type Stats, type StatsBuffer, type StatsRecording, type StatsSummary, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleTransitions, type Subscriber, type Summary, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformOrigin, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type UseRenderState, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, VisualElement, type VisualElementAnimationOptions, type VisualElementEventCallbacks, type VisualElementOptions, type VisualState, type WillChange, type WithAppearProps, type WithDepth, type WithQuerySelectorAll, acceleratedValues, activeAnimations, addAttrValue, addDomEvent, addScaleCorrector, addStyleValue, addValueToWillChange, alpha, analyseComplexValue, animateMotionValue, animateSingleValue, animateTarget, animateValue, animateVariant, animateView, animateVisualElement, animationMapKey, applyAxisDelta, applyBoxDelta, applyGeneratorOptions, applyPointDelta, applyPxDefaults, applyTreeDeltas, aspectRatio, attachFollow, attachSpring, attrEffect, axisDeltaEquals, axisEquals, axisEqualsRounded, boxEquals, boxEqualsRounded, buildHTMLStyles, buildProjectionTransform, buildSVGAttrs, buildSVGPath, buildTransform, calcAxisDelta, calcBoxDelta, calcChildStagger, calcGeneratorDuration, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, camelCaseAttributes, camelToDash, cancelFrame, cancelMicrotask, cancelSync, checkVariantsDidChange, cleanDirtyNodes, collectMotionValues, color, compareByDepth, complex, containsCSSVariable, convertBoundingBoxToBox, convertBoxToBoundingBox, convertOffsetToTimes, copyAxisDeltaInto, copyAxisInto, copyBoxInto, correctBorderRadius, correctBoxShadow, createAnimationState, createAxis, createAxisDelta, createBox, createDelta, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, eachAxis, fillOffset, fillWildcards, findDimensionValueType, findValueType, flushKeyframeResolvers, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, has2DTranslate, hasReducedMotionListener, hasScale, hasTransform, hex, hover, hsla, hslaToRgba, inertia, initPrefersReducedMotion, interpolate, invisibleValues, isAnimationControls, isCSSVariableName, isCSSVariableToken, isControllingVariants, isDeltaZero, isDragActive, isDragging, isElementKeyboardAccessible, isElementTextInput, isForcedMotionValue, isGenerator, isHTMLElement, isKeyframesTarget, isMotionValue, isNear, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isSVGTag, isTransitionDefined, isVariantLabel, isVariantNode, isWaapiSupportedEasing, isWillChangeMotionValue, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, measurePageBox, measureViewportBox, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixValues, mixVisibility, motionValue, nodeGroup, number, numberValueTypes, observeTimeline, optimizedAppearDataAttribute, optimizedAppearDataId, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pixelsToPercent, positionalKeys, prefersReducedMotion, press, progressPercentage, propEffect, propagateDirtyNodes, px, readTransformValue, recordStats, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removePointDelta, renderHTML, renderSVG, resize, resolveElements, resolveMotionValue, resolveTransition, resolveVariant, resolveVariantFromProps, rgbUnit, rgba, rootProjectionNode, scale, scaleCorrectors, scalePoint, scrapeMotionValuesFromProps$1 as scrapeHTMLMotionValuesFromProps, scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps, setDragLock, setFeatureDefinitions, setStyle, setTarget, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, svgEffect, sync, testValueType, time, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };
|
|
5051
|
+
export { type AcceptedAnimations, type ActiveStatsBuffer, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationList, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState, type AnimationType, type AnimationTypeState, type AnyResolvedKeyframe, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, DOMVisualElement, type DOMVisualElementOptions, type DecayOptions, type DelayedFunction, DocumentProjectionNode, type DragElastic, type DragHandler, type DraggableProps, type DurationSpringOptions, type DynamicOption, type ElementOrSelector, type EventInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type FrameStats, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, HTMLProjectionNode, type HTMLRenderState, HTMLVisualElement, type HandoffFunction, type IProjectionNode, type InactiveStatsBuffer, type InertiaOptions, type InitialPromotionConfig, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, LayoutAnimationBuilder, type LayoutEvents, type LayoutLifecycles, type LayoutUpdateData, type LayoutUpdateHandler, type LegacyAnimationControls, type MapInputRange, type Measurements, type Mixer, type MixerFactory, type MotionConfigContextProps, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, type MotionStyle, MotionValue, type MotionValueEventCallbacks, type MotionValueOptions, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NodeGroup, NodeStack, type NumberMap, ObjectVisualElement, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, type PassiveEffect, type Phase, type PointerEventOptions, type PresenceContextProps, type PressGestureInfo, type Process, type ProgressTimeline, type ProjectionEventName, type ProjectionNodeConfig, type ProjectionNodeOptions, type PropagateOptions, type RGBA, type ReducedMotionConfig, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues$1 as ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGRenderState, type SVGTransitions, SVGVisualElement, type ScaleCorrectionNode, type ScaleCorrector, type ScaleCorrectorDefinition, type ScaleCorrectorMap, type Schedule, type ScrapeMotionValuesFromProps, type ScrollMeasurements, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type Stats, type StatsBuffer, type StatsRecording, type StatsSummary, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleTransitions, type Subscriber, type Summary, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformOrigin, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type UseRenderState, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, VisualElement, type VisualElementAnimationOptions, type VisualElementEventCallbacks, type VisualElementOptions, type VisualState, type WillChange, type WithAppearProps, type WithDepth, type WithQuerySelectorAll, acceleratedValues, activeAnimations, addAttrValue, addDomEvent, addScaleCorrector, addStyleValue, addValueToWillChange, alpha, analyseComplexValue, animateMotionValue, animateSingleValue, animateTarget, animateValue, animateVariant, animateView, animateVisualElement, animationMapKey, applyAxisDelta, applyBoxDelta, applyGeneratorOptions, applyPointDelta, applyPxDefaults, applyTreeDeltas, aspectRatio, attachFollow, attachSpring, attrEffect, axisDeltaEquals, axisEquals, axisEqualsRounded, boxEquals, boxEqualsRounded, buildHTMLStyles, buildProjectionTransform, buildSVGAttrs, buildSVGPath, buildTransform, calcAxisDelta, calcBoxDelta, calcChildStagger, calcGeneratorDuration, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, camelCaseAttributes, camelToDash, cancelFrame, cancelMicrotask, cancelSync, checkVariantsDidChange, cleanDirtyNodes, collectMotionValues, color, compareByDepth, complex, containsCSSVariable, convertBoundingBoxToBox, convertBoxToBoundingBox, convertOffsetToTimes, copyAxisDeltaInto, copyAxisInto, copyBoxInto, correctBorderRadius, correctBoxShadow, createAnimationState, createAxis, createAxisDelta, createBox, createDelta, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, eachAxis, fillOffset, fillWildcards, findDimensionValueType, findValueType, flushKeyframeResolvers, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, has2DTranslate, hasReducedMotionListener, hasScale, hasTransform, hex, hover, hsla, hslaToRgba, inertia, initPrefersReducedMotion, interpolate, invisibleValues, isAnimationControls, isCSSVariableName, isCSSVariableToken, isControllingVariants, isDeltaZero, isDragActive, isDragging, isElementKeyboardAccessible, isElementTextInput, isForcedMotionValue, isGenerator, isHTMLElement, isKeyframesTarget, isMotionValue, isNear, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isSVGTag, isTransitionDefined, isVariantLabel, isVariantNode, isWaapiSupportedEasing, isWillChangeMotionValue, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, measurePageBox, measureViewportBox, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixValues, mixVisibility, motionValue, nodeGroup, number, numberValueTypes, observeTimeline, optimizedAppearDataAttribute, optimizedAppearDataId, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pixelsToPercent, positionalKeys, prefersReducedMotion, press, progressPercentage, propEffect, propagateDirtyNodes, px, readTransformValue, recordStats, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removePointDelta, renderHTML, renderSVG, resize, resolveElements, resolveMotionValue, resolveTransition, resolveVariant, resolveVariantFromProps, rgbUnit, rgba, rootProjectionNode, scale, scaleCorrectors, scalePoint, scrapeMotionValuesFromProps$1 as scrapeHTMLMotionValuesFromProps, scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps, setDragLock, setFeatureDefinitions, setStyle, setTarget, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, svgEffect, sync, testValueType, time, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };
|
package/dist/motion-dom.dev.js
CHANGED
|
@@ -4414,6 +4414,7 @@
|
|
|
4414
4414
|
function isValidPressEvent(event) {
|
|
4415
4415
|
return isPrimaryPointer(event) && !isDragActive();
|
|
4416
4416
|
}
|
|
4417
|
+
const claimedPointerDownEvents = new WeakSet();
|
|
4417
4418
|
/**
|
|
4418
4419
|
* Create a press gesture.
|
|
4419
4420
|
*
|
|
@@ -4439,7 +4440,12 @@
|
|
|
4439
4440
|
const target = startEvent.currentTarget;
|
|
4440
4441
|
if (!isValidPressEvent(startEvent))
|
|
4441
4442
|
return;
|
|
4443
|
+
if (claimedPointerDownEvents.has(startEvent))
|
|
4444
|
+
return;
|
|
4442
4445
|
isPressing.add(target);
|
|
4446
|
+
if (options.stopPropagation) {
|
|
4447
|
+
claimedPointerDownEvents.add(startEvent);
|
|
4448
|
+
}
|
|
4443
4449
|
const onPressEnd = onPressStart(target, startEvent);
|
|
4444
4450
|
const onPointerEnd = (endEvent, success) => {
|
|
4445
4451
|
window.removeEventListener("pointerup", onPointerUp);
|
|
@@ -6821,6 +6827,22 @@
|
|
|
6821
6827
|
typeof prop === "boolean") {
|
|
6822
6828
|
continue;
|
|
6823
6829
|
}
|
|
6830
|
+
/**
|
|
6831
|
+
* If exit is already active and wasn't just activated, skip
|
|
6832
|
+
* re-processing to prevent interrupting running exit animations.
|
|
6833
|
+
* Re-resolving exit with a changed custom value can start new
|
|
6834
|
+
* value animations that stop the originals, leaving the exit
|
|
6835
|
+
* animation promise unresolved and the component stuck in the DOM.
|
|
6836
|
+
*/
|
|
6837
|
+
if (type === "exit" && typeState.isActive && activeDelta !== true) {
|
|
6838
|
+
if (typeState.prevResolvedValues) {
|
|
6839
|
+
encounteredKeys = {
|
|
6840
|
+
...encounteredKeys,
|
|
6841
|
+
...typeState.prevResolvedValues,
|
|
6842
|
+
};
|
|
6843
|
+
}
|
|
6844
|
+
continue;
|
|
6845
|
+
}
|
|
6824
6846
|
/**
|
|
6825
6847
|
* As we go look through the values defined on this type, if we detect
|
|
6826
6848
|
* a changed value or a value that was removed in a higher priority, we set
|
|
@@ -7392,6 +7414,15 @@
|
|
|
7392
7414
|
}
|
|
7393
7415
|
add(node) {
|
|
7394
7416
|
motionUtils.addUniqueItem(this.members, node);
|
|
7417
|
+
for (let i = this.members.length - 1; i >= 0; i--) {
|
|
7418
|
+
const m = this.members[i];
|
|
7419
|
+
if (m === node || m === this.lead || m === this.prevLead)
|
|
7420
|
+
continue;
|
|
7421
|
+
const inst = m.instance;
|
|
7422
|
+
if (inst && inst.isConnected === false && m.isPresent !== false && !m.snapshot) {
|
|
7423
|
+
motionUtils.removeItem(this.members, m);
|
|
7424
|
+
}
|
|
7425
|
+
}
|
|
7395
7426
|
node.scheduleRender();
|
|
7396
7427
|
}
|
|
7397
7428
|
remove(node) {
|
|
@@ -7416,7 +7447,8 @@
|
|
|
7416
7447
|
let prevLead;
|
|
7417
7448
|
for (let i = indexOfNode; i >= 0; i--) {
|
|
7418
7449
|
const member = this.members[i];
|
|
7419
|
-
|
|
7450
|
+
const inst = member.instance;
|
|
7451
|
+
if (member.isPresent !== false && (!inst || inst.isConnected !== false)) {
|
|
7420
7452
|
prevLead = member;
|
|
7421
7453
|
break;
|
|
7422
7454
|
}
|
|
@@ -7451,17 +7483,21 @@
|
|
|
7451
7483
|
nextDep !== undefined &&
|
|
7452
7484
|
prevDep === nextDep;
|
|
7453
7485
|
if (!dependencyMatches) {
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
|
|
7462
|
-
|
|
7463
|
-
|
|
7464
|
-
|
|
7486
|
+
const prevInstance = prevLead.instance;
|
|
7487
|
+
const isStale = prevInstance && prevInstance.isConnected === false && !prevLead.snapshot;
|
|
7488
|
+
if (!isStale) {
|
|
7489
|
+
node.resumeFrom = prevLead;
|
|
7490
|
+
if (preserveFollowOpacity) {
|
|
7491
|
+
node.resumeFrom.preserveOpacity = true;
|
|
7492
|
+
}
|
|
7493
|
+
if (prevLead.snapshot) {
|
|
7494
|
+
node.snapshot = prevLead.snapshot;
|
|
7495
|
+
node.snapshot.latestValues =
|
|
7496
|
+
prevLead.animationValues || prevLead.latestValues;
|
|
7497
|
+
}
|
|
7498
|
+
if (node.root && node.root.isUpdating) {
|
|
7499
|
+
node.isLayoutDirty = true;
|
|
7500
|
+
}
|
|
7465
7501
|
}
|
|
7466
7502
|
}
|
|
7467
7503
|
const { crossfade } = node.options;
|