motion-dom 14.4.0 → 14.6.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/index.js +413 -79
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/NativeAnimation.mjs +10 -4
- package/dist/es/animation/NativeAnimation.mjs.map +1 -1
- package/dist/es/animation/animate/element.mjs +10 -1
- package/dist/es/animation/animate/element.mjs.map +1 -1
- package/dist/es/animation/generators/spring.mjs +11 -9
- package/dist/es/animation/generators/spring.mjs.map +1 -1
- package/dist/es/animation/keyframes/utils/unit-conversion.mjs +8 -7
- package/dist/es/animation/keyframes/utils/unit-conversion.mjs.map +1 -1
- package/dist/es/animation/optimized-appear/data-id.mjs +1 -3
- package/dist/es/animation/optimized-appear/data-id.mjs.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +8 -2
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/frameloop/process-frame.mjs +42 -0
- package/dist/es/frameloop/process-frame.mjs.map +1 -0
- package/dist/es/frameloop/render-step.mjs +15 -1
- package/dist/es/frameloop/render-step.mjs.map +1 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +16 -6
- package/dist/es/gestures/drag/VisualElementDragControls.mjs.map +1 -1
- package/dist/es/gestures/drag/index.mjs +16 -1
- package/dist/es/gestures/drag/index.mjs.map +1 -1
- package/dist/es/gestures/hover.mjs +2 -0
- package/dist/es/gestures/hover.mjs.map +1 -1
- package/dist/es/gestures/pan/PanSession.mjs +6 -0
- package/dist/es/gestures/pan/PanSession.mjs.map +1 -1
- package/dist/es/gestures/press/index.mjs +3 -1
- package/dist/es/gestures/press/index.mjs.map +1 -1
- package/dist/es/gestures/press/utils/keyboard.mjs +22 -12
- package/dist/es/gestures/press/utils/keyboard.mjs.map +1 -1
- package/dist/es/gestures/utils/setup.mjs +2 -1
- package/dist/es/gestures/utils/setup.mjs.map +1 -1
- package/dist/es/index.mjs +7 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/layout/LayoutAnimationBuilder.mjs +2 -1
- package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
- package/dist/es/layout/animate-layout.mjs +7 -1
- package/dist/es/layout/animate-layout.mjs.map +1 -1
- package/dist/es/projection/node/DocumentProjectionNode.mjs +8 -3
- package/dist/es/projection/node/DocumentProjectionNode.mjs.map +1 -1
- package/dist/es/projection/node/HTMLProjectionNode.mjs +4 -5
- package/dist/es/projection/node/HTMLProjectionNode.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +21 -12
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/projection/node/root.mjs +6 -0
- package/dist/es/projection/node/root.mjs.map +1 -0
- package/dist/es/projection/styles/default-scale-correctors.mjs +3 -4
- package/dist/es/projection/styles/default-scale-correctors.mjs.map +1 -1
- package/dist/es/render/utils/animation-state.mjs +1 -2
- package/dist/es/render/utils/animation-state.mjs.map +1 -1
- package/dist/es/render/utils/variant-props.mjs +1 -1
- package/dist/es/render/utils/variant-props.mjs.map +1 -1
- package/dist/es/resize/index.mjs +2 -1
- package/dist/es/resize/index.mjs.map +1 -1
- package/dist/es/scope/active.mjs +39 -0
- package/dist/es/scope/active.mjs.map +1 -0
- package/dist/es/scope/index.mjs +122 -0
- package/dist/es/scope/index.mjs.map +1 -0
- package/dist/es/scope/media.mjs +42 -0
- package/dist/es/scope/media.mjs.map +1 -0
- package/dist/es/utils/delay.mjs +3 -1
- package/dist/es/utils/delay.mjs.map +1 -1
- package/dist/es/utils/resolve-elements.mjs +5 -4
- package/dist/es/utils/resolve-elements.mjs.map +1 -1
- package/dist/es/view/index.mjs +4 -1
- package/dist/es/view/index.mjs.map +1 -1
- package/dist/index.d.ts +178 -15
- package/dist/motion-dom.dev.js +413 -79
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-motion-value.js +1 -1
- package/dist/size-rollup-motion-value.js.map +1 -1
- package/dist/size-rollup-style-effect.js +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +4 -4
|
@@ -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\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 /**\n * End listeners run in the capture phase so a descendant calling\n * stopPropagation() in its own pointerup handler can't prevent the\n * press gesture from ending. This also keeps the gesture-end\n * ordering consistent with the drag gesture. See #2794.\n */\n const endEventOptions = { ...eventOptions, capture: true }\n\n const onPointerEnd = (endEvent: PointerEvent, success: boolean) => {\n window.removeEventListener(\n \"pointerup\",\n onPointerUp,\n endEventOptions\n )\n window.removeEventListener(\n \"pointercancel\",\n onPointerCancel,\n endEventOptions\n )\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, endEventOptions)\n window.addEventListener(\n \"pointercancel\",\n onPointerCancel,\n endEventOptions\n )\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\"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../../src/gestures/press/index.ts"],"sourcesContent":["import { bindToScope } from \"../../scope/active\"\nimport { 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 onPressStart = bindToScope(onPressStart)\n\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 /**\n * End listeners run in the capture phase so a descendant calling\n * stopPropagation() in its own pointerup handler can't prevent the\n * press gesture from ending. This also keeps the gesture-end\n * ordering consistent with the drag gesture. See #2794.\n */\n const endEventOptions = { ...eventOptions, capture: true }\n\n const onPointerEnd = (endEvent: PointerEvent, success: boolean) => {\n window.removeEventListener(\n \"pointerup\",\n onPointerUp,\n endEventOptions\n )\n window.removeEventListener(\n \"pointercancel\",\n onPointerCancel,\n endEventOptions\n )\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, endEventOptions)\n window.addEventListener(\n \"pointercancel\",\n onPointerCancel,\n endEventOptions\n )\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(\n \"focus\",\n () => enableKeyboardPress(target, eventOptions),\n 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":";;;;;;;;;;AAaA;;;AAGG;AACH,SAAS,iBAAiB,CAAC,KAAmB,EAAA;IAC1C,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE;AACrD;AAEA,MAAM,wBAAwB,GAAG,IAAI,OAAO,EAAS;AAOrD;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,KAAK,CACjB,gBAAmC,EACnC,YAA+B,EAC/B,UAA+B,EAAE,EAAA;AAEjC,IAAA,YAAY,GAAG,WAAW,CAAC,YAA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AAc,KAAK,MAAM;AACrB,gBAAA,MAAc,KAAK,QAAQ;AAC5B,gBAAA,OAAO,CAAC,eAAe;gBACvB,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,MAAiB,CAAC,CACvD;AACL,QAAA,CAAC;AAED,QAAA,MAAM,eAAe,GAAG,CAAC,WAAyB,KAAI;AAClD,YAAA,YAAY,CAAC,WAAW,EAAE,KAAK,CAAC;AACpC,QAAA,CAAC;QAED,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,EAAE,eAAe,CAAC;QAClE,MAAM,CAAC,gBAAgB,CACnB,eAAe,EACf,eAAe,EACf,eAAe,CAClB;AACL,IAAA,CAAC;AAED,IAAA,OAAO,CAAC,OAAO,CAAC,CAAC,MAAmB,KAAI;AACpC,QAAA,MAAM,iBAAiB,GAAG,OAAO,CAAC,eAAe,GAAG,MAAM,GAAG,MAAM;QACnE,iBAAiB,CAAC,gBAAgB,CAC9B,aAAa,EACb,UAA2B,EAC3B,YAAY,CACf;AAED,QAAA,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;AACvB,YAAA,MAAM,CAAC,gBAAgB,CACnB,OAAO,EACP,MAAM,mBAAmB,CAAC,MAAM,EAAE,YAAY,CAAC,EAC/C,YAAY,CACf;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;YACvB;QACJ;AACJ,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,YAAY;AACvB;;;;"}
|
|
@@ -13,26 +13,36 @@ function filterEvents(callback) {
|
|
|
13
13
|
function firePointerEvent(target, type) {
|
|
14
14
|
target.dispatchEvent(new PointerEvent("pointer" + type, { isPrimary: true, bubbles: true }));
|
|
15
15
|
}
|
|
16
|
-
const enableKeyboardPress = (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const enableKeyboardPress = (element, eventOptions) => {
|
|
17
|
+
/**
|
|
18
|
+
* Listeners are scoped to this focus and all released on blur, rather
|
|
19
|
+
* than added per Enter press, so they can't accumulate and fire
|
|
20
|
+
* duplicate pointerup/pointercancel events. See #3935.
|
|
21
|
+
*/
|
|
22
|
+
let isKeyPressing = false;
|
|
20
23
|
const handleKeydown = filterEvents(() => {
|
|
21
24
|
if (isPressing.has(element))
|
|
22
25
|
return;
|
|
26
|
+
isKeyPressing = true;
|
|
23
27
|
firePointerEvent(element, "down");
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
element
|
|
28
|
+
});
|
|
29
|
+
const handleKeyup = filterEvents(() => {
|
|
30
|
+
if (!isKeyPressing)
|
|
31
|
+
return;
|
|
32
|
+
isKeyPressing = false;
|
|
33
|
+
firePointerEvent(element, "up");
|
|
30
34
|
});
|
|
31
35
|
element.addEventListener("keydown", handleKeydown, eventOptions);
|
|
36
|
+
element.addEventListener("keyup", handleKeyup, eventOptions);
|
|
32
37
|
/**
|
|
33
|
-
*
|
|
38
|
+
* On blur, remove the key listeners and cancel any keyboard press.
|
|
34
39
|
*/
|
|
35
|
-
element.addEventListener("blur", () =>
|
|
40
|
+
element.addEventListener("blur", () => {
|
|
41
|
+
element.removeEventListener("keydown", handleKeydown);
|
|
42
|
+
element.removeEventListener("keyup", handleKeyup);
|
|
43
|
+
if (isKeyPressing)
|
|
44
|
+
firePointerEvent(element, "cancel");
|
|
45
|
+
}, { ...eventOptions, once: true });
|
|
36
46
|
};
|
|
37
47
|
|
|
38
48
|
export { enableKeyboardPress };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard.mjs","sources":["../../../../../src/gestures/press/utils/keyboard.ts"],"sourcesContent":["import { isPressing } from \"./state\"\n\n/**\n * Filter out events that are not \"Enter\" keys.\n */\nfunction filterEvents(callback: (event: KeyboardEvent) => void) {\n return (event: KeyboardEvent) => {\n if (event.key !== \"Enter\") return\n callback(event)\n }\n}\n\nfunction firePointerEvent(target: EventTarget, type: \"down\" | \"up\" | \"cancel\") {\n target.dispatchEvent(\n new PointerEvent(\"pointer\" + type, { isPrimary: true, bubbles: true })\n )\n}\n\nexport const enableKeyboardPress = (\n
|
|
1
|
+
{"version":3,"file":"keyboard.mjs","sources":["../../../../../src/gestures/press/utils/keyboard.ts"],"sourcesContent":["import { isPressing } from \"./state\"\n\n/**\n * Filter out events that are not \"Enter\" keys.\n */\nfunction filterEvents(callback: (event: KeyboardEvent) => void) {\n return (event: KeyboardEvent) => {\n if (event.key !== \"Enter\") return\n callback(event)\n }\n}\n\nfunction firePointerEvent(target: EventTarget, type: \"down\" | \"up\" | \"cancel\") {\n target.dispatchEvent(\n new PointerEvent(\"pointer\" + type, { isPrimary: true, bubbles: true })\n )\n}\n\nexport const enableKeyboardPress = (\n element: HTMLElement,\n eventOptions: AddEventListenerOptions\n) => {\n /**\n * Listeners are scoped to this focus and all released on blur, rather\n * than added per Enter press, so they can't accumulate and fire\n * duplicate pointerup/pointercancel events. See #3935.\n */\n let isKeyPressing = false\n\n const handleKeydown = filterEvents(() => {\n if (isPressing.has(element)) return\n isKeyPressing = true\n firePointerEvent(element, \"down\")\n })\n\n const handleKeyup = filterEvents(() => {\n if (!isKeyPressing) return\n isKeyPressing = false\n firePointerEvent(element, \"up\")\n })\n\n element.addEventListener(\"keydown\", handleKeydown, eventOptions)\n element.addEventListener(\"keyup\", handleKeyup, eventOptions)\n\n /**\n * On blur, remove the key listeners and cancel any keyboard press.\n */\n element.addEventListener(\n \"blur\",\n () => {\n element.removeEventListener(\"keydown\", handleKeydown)\n element.removeEventListener(\"keyup\", handleKeyup)\n if (isKeyPressing) firePointerEvent(element, \"cancel\")\n },\n { ...eventOptions, once: true }\n )\n}\n"],"names":[],"mappings":";;AAEA;;AAEG;AACH,SAAS,YAAY,CAAC,QAAwC,EAAA;IAC1D,OAAO,CAAC,KAAoB,KAAI;AAC5B,Q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AE,IAAI,EAAE,IAAI,EAAE,CAClC;AACL;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolveElements } from '../../utils/resolve-elements.mjs';
|
|
2
|
+
import { addToScope } from '../../scope/active.mjs';
|
|
2
3
|
|
|
3
4
|
function setupGesture(elementOrSelector, options) {
|
|
4
5
|
const elements = resolveElements(elementOrSelector);
|
|
@@ -8,7 +9,7 @@ function setupGesture(elementOrSelector, options) {
|
|
|
8
9
|
...options,
|
|
9
10
|
signal: gestureAbortController.signal,
|
|
10
11
|
};
|
|
11
|
-
const cancel = () => gestureAbortController.abort();
|
|
12
|
+
const cancel = addToScope(() => gestureAbortController.abort());
|
|
12
13
|
return [elements, eventOptions, cancel];
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.mjs","sources":["../../../../src/gestures/utils/setup.ts"],"sourcesContent":["import {\n ElementOrSelector,\n resolveElements,\n} from \"../../utils/resolve-elements\"\nimport { EventOptions } from \"../types\"\n\nexport function setupGesture(\n elementOrSelector: ElementOrSelector,\n options: EventOptions\n): [Element[], AddEventListenerOptions, VoidFunction] {\n const elements = resolveElements(elementOrSelector)\n\n const gestureAbortController = new AbortController()\n\n const eventOptions = {\n passive: true,\n ...options,\n signal: gestureAbortController.signal,\n }\n\n const cancel = () => gestureAbortController.abort()\n\n return [elements, eventOptions, cancel]\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setup.mjs","sources":["../../../../src/gestures/utils/setup.ts"],"sourcesContent":["import {\n ElementOrSelector,\n resolveElements,\n} from \"../../utils/resolve-elements\"\nimport { addToScope } from \"../../scope/active\"\nimport { EventOptions } from \"../types\"\n\nexport function setupGesture(\n elementOrSelector: ElementOrSelector,\n options: EventOptions\n): [Element[], AddEventListenerOptions, VoidFunction] {\n const elements = resolveElements(elementOrSelector)\n\n const gestureAbortController = new AbortController()\n\n const eventOptions = {\n passive: true,\n ...options,\n signal: gestureAbortController.signal,\n }\n\n const cancel = addToScope(() => gestureAbortController.abort())\n\n return [elements, eventOptions, cancel]\n}\n"],"names":[],"mappings":";;;AAOM,SAAU,YAAY,CACxB,iBAAoC,EACpC,OAAqB,EAAA;AAErB,IAAA,MAAM,QAAQ,GAAG,eAAe,CAAC,iBAAiB,CAAC;AAEnD,IAAA,MAAM,sBAAsB,GAAG,IAAI,eAAe,EAAE;AAEpD,IAAA,MAAM,YAAY,GAAG;AACjB,QAAA,OAAO,EAAE,IAAI;AACb,QAAA,GAAG,OAAO;QACV,MAAM,EAAE,sBAAsB,CAAC,MAAM;KACxC;AAED,IAAA,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,sBAAsB,CAAC,KAAK,EAAE,CAAC;AAE/D,IAAA,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC;AAC3C;;;;"}
|
package/dist/es/index.mjs
CHANGED
|
@@ -46,7 +46,7 @@ export { acceleratedValues } from './animation/waapi/utils/accelerated-values.mj
|
|
|
46
46
|
export { applyGeneratorOptions } from './animation/waapi/utils/apply-generator.mjs';
|
|
47
47
|
export { generateLinearEasing } from './animation/waapi/utils/linear.mjs';
|
|
48
48
|
export { addEffect, animateEffectSubject, animateValues, findEffect, removeEffect } from './animation/animate/effects.mjs';
|
|
49
|
-
export { animateElement, handOffElementState } from './animation/animate/element.mjs';
|
|
49
|
+
export { animateElement, handOffElementState, releaseElement } from './animation/animate/element.mjs';
|
|
50
50
|
export { addAttrValue, attrEffect } from './effects/attr/index.mjs';
|
|
51
51
|
export { MotionValueState } from './effects/MotionValueState.mjs';
|
|
52
52
|
export { propEffect } from './effects/prop/index.mjs';
|
|
@@ -55,6 +55,7 @@ export { addSVGValue, readSVGValue, svgEffect, svgSubjectEffect } from './effect
|
|
|
55
55
|
export { createEffect } from './effects/utils/create-effect.mjs';
|
|
56
56
|
export { createRenderBatcher } from './frameloop/batcher.mjs';
|
|
57
57
|
export { cancelMicrotask, microtask } from './frameloop/microtask.mjs';
|
|
58
|
+
export { processFrame } from './frameloop/process-frame.mjs';
|
|
58
59
|
export { time } from './frameloop/sync-time.mjs';
|
|
59
60
|
export { drag } from './gestures/drag/index.mjs';
|
|
60
61
|
export { isDragActive, isDragging } from './gestures/drag/state/is-active.mjs';
|
|
@@ -73,6 +74,9 @@ export { isKeyframesTarget } from './render/utils/is-keyframes-target.mjs';
|
|
|
73
74
|
export { positionalKeys } from './render/utils/keys-position.mjs';
|
|
74
75
|
export { transformPropOrder, transformProps } from './render/utils/keys-transform.mjs';
|
|
75
76
|
export { resize } from './resize/index.mjs';
|
|
77
|
+
export { scopeMotion } from './scope/index.mjs';
|
|
78
|
+
export { activeScope, addBuilderToScope, addToScope, bindToScope } from './scope/active.mjs';
|
|
79
|
+
export { toMediaQuery } from './scope/media.mjs';
|
|
76
80
|
export { recordStats } from './stats/index.mjs';
|
|
77
81
|
export { statsBuffer } from './stats/buffer.mjs';
|
|
78
82
|
export { interpolate } from './utils/interpolate.mjs';
|
|
@@ -163,7 +167,8 @@ export { resolveMotionValue } from './value/utils/resolve-motion-value.mjs';
|
|
|
163
167
|
export { cleanDirtyNodes, createProjectionNode, propagateDirtyNodes } from './projection/node/create-projection-node.mjs';
|
|
164
168
|
export { DocumentProjectionNode } from './projection/node/DocumentProjectionNode.mjs';
|
|
165
169
|
export { nodeGroup } from './projection/node/group.mjs';
|
|
166
|
-
export { HTMLProjectionNode
|
|
170
|
+
export { HTMLProjectionNode } from './projection/node/HTMLProjectionNode.mjs';
|
|
171
|
+
export { rootProjectionNode } from './projection/node/root.mjs';
|
|
167
172
|
export { globalProjectionState } from './projection/node/state.mjs';
|
|
168
173
|
export { NodeStack } from './projection/shared/stack.mjs';
|
|
169
174
|
export { camelToDash } from './render/dom/utils/camel-to-dash.mjs';
|
package/dist/es/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { activeScope } from '../scope/active.mjs';
|
|
1
2
|
import { clamp } from 'motion-utils';
|
|
2
3
|
import { handOffElementState } from '../animation/animate/element.mjs';
|
|
3
4
|
import { GroupAnimation } from '../animation/GroupAnimation.mjs';
|
|
@@ -364,7 +365,7 @@ class LayoutAnimationBuilder {
|
|
|
364
365
|
function parseAnimateLayoutArgs(scopeOrUpdateDom, updateDomOrOptions, options) {
|
|
365
366
|
if (typeof scopeOrUpdateDom === "function") {
|
|
366
367
|
return {
|
|
367
|
-
scope: document,
|
|
368
|
+
scope: activeScope.current?.root || document,
|
|
368
369
|
updateDom: scopeOrUpdateDom,
|
|
369
370
|
defaultOptions: updateDomOrOptions,
|
|
370
371
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutAnimationBuilder.mjs","sources":["../../../src/layout/LayoutAnimationBuilder.ts"],"sourcesContent":["import { clamp } from \"motion-utils\"\nimport { handOffElementState } from \"../animation/animate/element\"\nimport { GroupAnimation } from \"../animation/GroupAnimation\"\nimport type { AnimationOptions, Transition } from \"../animation/types\"\nimport { frameData, frameSteps } from \"../frameloop\"\nimport { microtask } from \"../frameloop/microtask\"\nimport { time } from \"../frameloop/sync-time\"\nimport { HTMLProjectionNode } from \"../projection/node/HTMLProjectionNode\"\nimport type { IProjectionNode } from \"../projection/node/types\"\nimport { HTMLVisualElement } from \"../render/html/HTMLVisualElement\"\nimport { visualElementStore } from \"../render/store\"\nimport { hasTransform } from \"../projection/utils/has-transform\"\nimport {\n resolveElements,\n type ElementOrSelector,\n} from \"../utils/resolve-elements\"\n\ntype LayoutAnimationScope = Element | Document\ntype LayoutBuilderResolve = (animation: GroupAnimation) => void\ntype LayoutBuilderReject = (error: unknown) => void\n\ninterface RestorePoint {\n parent: Element\n next: ChildNode | null\n}\n\nconst layoutSelector = \"[data-layout],[data-layout-id]\"\n\n/**\n * All imperatively-created projection nodes live in one persistent tree,\n * shared across animateLayout() calls (and with any React-created nodes,\n * via the singleton document root). Keyed by element for reuse.\n */\nconst layoutNodes = new WeakMap<Element, IProjectionNode>()\n\n/**\n * Builders created within the same synchronous tick are flushed together\n * as a single \"commit\": every node is snapshotted before any updateDom\n * runs, mirroring React batching renders from different parts of the tree.\n */\nlet pendingBuilders: LayoutAnimationBuilder[] | undefined\n\nfunction collectLayoutElements(scope: LayoutAnimationScope): HTMLElement[] {\n const elements: HTMLElement[] = []\n\n if (scope instanceof HTMLElement && scope.matches(layoutSelector)) {\n elements.push(scope)\n }\n\n scope.querySelectorAll(layoutSelector).forEach((element) => {\n if (element instanceof HTMLElement) elements.push(element)\n })\n\n return elements\n}\n\n/**\n * Process any work scheduled on the frameloop now. A previous animation\n * may have been seeked while paused (controls.time = x) without a frame\n * having rendered it - we must materialise that state into the DOM\n * before taking snapshots.\n */\nfunction flushPendingFrame() {\n if (frameData.isProcessing) return\n\n const now = time.now()\n frameData.delta = clamp(0, 1000 / 60, now - frameData.timestamp)\n frameData.timestamp = now\n frameData.isProcessing = true\n frameSteps.update.process(frameData)\n frameSteps.preRender.process(frameData)\n frameSteps.render.process(frameData)\n frameData.isProcessing = false\n}\n\nfunction getProjectionParent(element: Element): IProjectionNode | undefined {\n let ancestor = element.parentElement\n while (ancestor) {\n const node = layoutNodes.get(ancestor)\n if (node && node.instance) return node\n ancestor = ancestor.parentElement\n }\n return undefined\n}\n\nfunction createVisualElement() {\n return new HTMLVisualElement(\n {\n props: {},\n presenceContext: null,\n visualState: {\n latestValues: {},\n renderState: {\n transform: {},\n transformOrigin: {},\n style: {},\n vars: {},\n },\n },\n },\n { allowProjection: true }\n )\n}\n\nfunction readNodeOptions(element: HTMLElement, transition?: Transition) {\n const layoutAttr = element.getAttribute(\"data-layout\")\n const layoutId = element.getAttribute(\"data-layout-id\") ?? undefined\n\n return {\n layoutId,\n layout: layoutAttr !== null ? true : undefined,\n animationType: (!layoutAttr || layoutAttr === \"true\"\n ? \"both\"\n : layoutAttr) as \"both\",\n transition,\n }\n}\n\nfunction prepareNode(\n element: HTMLElement,\n transition?: Transition\n): IProjectionNode {\n let node = layoutNodes.get(element)\n\n if (!node) {\n let visualElement = visualElementStore.get(element) as\n | HTMLVisualElement\n | undefined\n\n if (!visualElement) {\n visualElement = createVisualElement()\n\n /**\n * Values animate() has been rendering on this element move to\n * the VisualElement, so the layout animation composes with\n * them instead of overwriting them.\n */\n handOffElementState(element, visualElement)\n }\n\n /**\n * A first-time element may carry a projection transform in its\n * inline style (e.g. it was cloned from an element mid-animation).\n * That transform isn't tracked in latestValues so the engine can't\n * reset it before measuring - clear it now so the first layout\n * measurement isn't inflated.\n */\n if (\n element.style.transform &&\n !hasTransform(visualElement.latestValues)\n ) {\n element.style.transform = \"\"\n }\n\n node = new HTMLProjectionNode(\n visualElement.latestValues,\n getProjectionParent(element)\n )\n visualElement.projection = node\n\n node.setOptions({\n ...readNodeOptions(element, transition),\n visualElement,\n })\n node.mount(element)\n layoutNodes.set(element, node)\n } else {\n node.setOptions(readNodeOptions(element, transition))\n }\n\n node.isPresent = true\n if (node.options.onExitComplete) {\n node.setOptions({ onExitComplete: undefined })\n }\n\n return node\n}\n\n/**\n * Get a projection node for an element, so imperative gestures like\n * drag() can measure its layout. Reuses a node owned by a `motion`\n * component or animateLayout(), otherwise creates one in the shared\n * imperative tree. Returns the node and a function that releases it.\n */\nexport function acquireProjectionNode(\n element: HTMLElement\n): [IProjectionNode, VoidFunction] {\n const owned =\n layoutNodes.get(element) || visualElementStore.get(element)?.projection\n\n /**\n * A VisualElement can outlive a node we released (e.g. a stopped\n * drag()), so only reuse a node that's still mounted.\n */\n if (owned?.instance) return [owned, () => {}]\n\n const node = prepareNode(element)\n\n return [\n node,\n () => layoutNodes.get(element) === node && dropNode(element, node),\n ]\n}\n\nfunction sortDocumentOrder(elements: Iterable<HTMLElement>) {\n return [...elements].sort((a, b) =>\n a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1\n )\n}\n\nfunction dropNode(element: Element, node: IProjectionNode) {\n node.setOptions({ onExitComplete: undefined })\n\n /**\n * Stop any lingering animation so it can't leak into future updates.\n * A follow node can share its currentAnimation with a surviving lead\n * (via resumingFrom), in which case it isn't ours to stop.\n */\n const stack = node.getStack()\n if (!stack || node.isLead()) node.currentAnimation?.stop()\n\n node.unmount()\n layoutNodes.delete(element)\n}\n\nfunction flushPendingBuilders() {\n const builders = pendingBuilders!\n pendingBuilders = undefined\n\n flushPendingFrame()\n\n /**\n * Discover and mount every node across all builders before snapshotting\n * any of them. Mounting during an active update flags isLayoutDirty,\n * which would make that node's own willUpdate skip its snapshot.\n * Document order guarantees ancestors mount before descendants, even\n * when they're discovered by different builders.\n */\n const targets = new Map<HTMLElement, LayoutAnimationBuilder[]>()\n for (const builder of builders) {\n for (const element of builder.collectTargets()) {\n const owners = targets.get(element)\n owners ? owners.push(builder) : targets.set(element, [builder])\n }\n }\n\n const union = new Map<HTMLElement, IProjectionNode>()\n for (const element of sortDocumentOrder(targets.keys())) {\n const owners = targets.get(element)!\n const node = prepareNode(\n element,\n owners[owners.length - 1].transitionFor(element)\n )\n for (const owner of owners) owner.adopt(element, node)\n union.set(element, node)\n }\n\n union.forEach((node) => {\n node.isLayoutDirty = false\n node.willUpdate()\n })\n\n const updatePromises: Promise<void>[] = []\n for (const builder of builders) {\n const result = builder.runUpdate()\n if (result) updatePromises.push(result)\n }\n\n const commit = () => {\n /**\n * Process all additions before any removals so that, even across\n * builders, a removed member knows whether a replacement with the\n * same layoutId was added in this commit.\n */\n const newMemberIds = new Set<string>()\n for (const builder of builders) {\n builder.reconcileAdditions(newMemberIds)\n }\n for (const builder of builders) {\n builder.reconcileRemovals(newMemberIds)\n }\n\n let root: IProjectionNode | undefined\n union.forEach((node) => (root ||= node.root))\n for (const builder of builders) root ||= builder.getRoot()\n\n root?.didUpdate()\n\n /**\n * The root flushes the update on a microtask, synchronously\n * processing the frame that creates the layout animations. Collect\n * them in a later microtask step of the same pass.\n */\n microtask.render(() => {\n for (const builder of builders) builder.finalize()\n })\n }\n\n updatePromises.length ? Promise.all(updatePromises).then(commit) : commit()\n}\n\nexport class LayoutAnimationBuilder {\n private sharedTransitions = new Map<string, AnimationOptions>()\n\n private notifyReady: LayoutBuilderResolve = () => {}\n private rejectReady: LayoutBuilderReject = () => {}\n private readyPromise: Promise<GroupAnimation>\n\n private tracked = new Map<HTMLElement, IProjectionNode>()\n private restorePoints = new Map<HTMLElement, RestorePoint>()\n private updateError: unknown\n\n constructor(\n private scope: LayoutAnimationScope,\n private updateDom: () => void | Promise<void>,\n private defaultOptions?: AnimationOptions\n ) {\n this.readyPromise = new Promise<GroupAnimation>((resolve, reject) => {\n this.notifyReady = resolve\n this.rejectReady = reject\n })\n\n if (!pendingBuilders) {\n pendingBuilders = []\n queueMicrotask(flushPendingBuilders)\n }\n pendingBuilders.push(this)\n }\n\n shared(id: string, transition: AnimationOptions): this {\n this.sharedTransitions.set(id, transition)\n return this\n }\n\n then(resolve: LayoutBuilderResolve, reject?: LayoutBuilderReject) {\n return this.readyPromise.then(resolve, reject)\n }\n\n transitionFor(element: HTMLElement): Transition | undefined {\n const layoutId = element.getAttribute(\"data-layout-id\")\n return ((layoutId && this.sharedTransitions.get(layoutId)) ||\n this.defaultOptions) as Transition | undefined\n }\n\n adopt(element: HTMLElement, node: IProjectionNode) {\n this.tracked.set(element, node)\n this.restorePoints.set(element, {\n parent: element.parentElement!,\n next: element.nextSibling,\n })\n }\n\n collectTargets() {\n return collectLayoutElements(this.scope)\n }\n\n runUpdate(): Promise<void> | undefined {\n try {\n const result = this.updateDom()\n if (result && typeof result.then === \"function\") {\n return result.then(undefined, (error: unknown) => {\n this.updateError = error\n })\n }\n } catch (error) {\n this.updateError = error\n }\n return undefined\n }\n\n reconcileAdditions(newMemberIds: Set<string>) {\n for (const element of collectLayoutElements(this.scope)) {\n if (this.tracked.has(element)) continue\n const node = prepareNode(element, this.transitionFor(element))\n this.adopt(element, node)\n node.options.layoutId && newMemberIds.add(node.options.layoutId)\n }\n }\n\n reconcileRemovals(newMemberIds: Set<string>) {\n this.tracked.forEach((node, element) => {\n if (element.isConnected) return\n\n const restore = this.restorePoints.get(element)\n this.restorePoints.delete(element)\n\n const { layoutId } = node.options\n const stack = node.getStack()\n const hasSurvivor =\n stack &&\n stack.members.some(\n (member) =>\n member !== node &&\n (member.instance as HTMLElement | undefined)\n ?.isConnected\n )\n\n /**\n * A removed lead with a surviving stack member - and no\n * replacement member added this commit - runs an exit\n * crossfade: restore the element to its old position in the\n * DOM, relegate it and let the survivor take over. It's\n * removed again once the animation completes.\n */\n if (\n layoutId &&\n node.isLead() &&\n hasSurvivor &&\n !newMemberIds.has(layoutId)\n ) {\n if (restore && restore.parent.isConnected) {\n restore.parent.insertBefore(\n element,\n restore.next && restore.next.parentNode === restore.parent\n ? restore.next\n : null\n )\n node.isPresent = false\n node.setOptions({\n onExitComplete: () => {\n element.remove()\n dropNode(element, node)\n },\n })\n if (node.relegate()) return\n\n element.remove()\n }\n }\n\n dropNode(element, node)\n this.tracked.delete(element)\n })\n }\n\n getRoot(): IProjectionNode | undefined {\n let root: IProjectionNode | undefined\n this.tracked.forEach((node) => (root ||= node.root))\n return root\n }\n\n finalize() {\n if (this.updateError) {\n this.rejectReady(this.updateError)\n return\n }\n\n const animations = new Set<GroupAnimation[\"animations\"][number]>()\n this.tracked.forEach((node) => {\n if (node.instance && node.currentAnimation) {\n animations.add(node.currentAnimation)\n }\n })\n\n this.notifyReady(new GroupAnimation([...animations]))\n }\n}\n\nexport function parseAnimateLayoutArgs(\n scopeOrUpdateDom: ElementOrSelector | (() => void),\n updateDomOrOptions?: (() => void) | AnimationOptions,\n options?: AnimationOptions\n): {\n scope: Element | Document\n updateDom: () => void\n defaultOptions?: AnimationOptions\n} {\n if (typeof scopeOrUpdateDom === \"function\") {\n return {\n scope: document,\n updateDom: scopeOrUpdateDom,\n defaultOptions: updateDomOrOptions as AnimationOptions | undefined,\n }\n }\n\n const scope =\n scopeOrUpdateDom instanceof Document\n ? scopeOrUpdateDom\n : resolveElements(scopeOrUpdateDom)[0] ?? document\n\n return {\n scope,\n updateDom: updateDomOrOptions as () => void,\n defaultOptions: options,\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AA0BA,MAAM,cAAc,GAAG,gCAAgC;AAEvD;;;;AAIG;AACH,MAAM,WAAW,GAAG,IAAI,OAAO,EAA4B;AAE3D;;;;AAIG;AACH,IAAI,eAAqD;AAEzD,SAAS,qBAAqB,CAAC,KAA2B,EAAA;IACtD,MAAM,QAAQ,GAAkB,EAAE;IAElC,IAAI,KAAK,YAAY,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;AAC/D,QAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;IACxB;IAEA,KAAK,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,KAAI;QACvD,IAAI,OAAO,YAAY,WAAW;AAAE,YAAA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;AAC9D,IAAA,CAAC,CAAC;AAEF,IAAA,OAAO,QAAQ;AACnB;AAEA;;;;;AAKG;AACH,SAAS,iBAAiB,GAAA;IACtB,IAAI,SAAS,CAAC,YAAY;QAAE;AAE5B,IAAA,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;AACtB,IAAA,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,SAAS,CAAC,SAAS,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QACrC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,MAAM,IAAI,KAAJ,IAAI,GAAK,IAAI,CAAC,IAAI,CAAA,CAAC,CAAC;AACpD,QAAA,OAAO,IAAI;IACf;IAEA,QAAQ,GAAA;AACJ,QAAA,IAAI,IAAI,CAAC,WAAW,EAAE;AAClB,YAAA,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC;YAClC;QACJ;AAEA,QAAA,MAAM,UAAU,GAAG,IAAI,GAAG,EAAwC;QAClE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;YAC1B,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,gBAAgB,EAAE;AACxC,gBAAA,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC;YACzC;AACJ,QAAA,CAAC,CAAC;AAEF,QAAA,IAAI,CAAC,WAAW,CAAC,IAAI,cAAc,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IACzD;AACH;SAEe,sBAAsB,CAClC,gBAAkD,EAClD,kBAAoD,EACpD,OAA0B,EAAA;AAM1B,IAAA,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE;QACxC,OAAO;AACH,YAAA,KAAK,EAAE,QAAQ;AACf,YAAA,SAAS,EAAE,gBAAgB;AAC3B,YAAA,cAAc,EAAE,kBAAkD;SACrE;IACL;AAEA,IAAA,MAAM,KAAK,GACP,gBAAgB,YAAY;AACxB,UAAE;UACA,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ;IAE1D,OAAO;QACH,KAAK;AACL,QAAA,SAAS,EAAE,kBAAgC;AAC3C,QAAA,cAAc,EAAE,OAAO;KAC1B;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"LayoutAnimationBuilder.mjs","sources":["../../../src/layout/LayoutAnimationBuilder.ts"],"sourcesContent":["import { activeScope } from \"../scope/active\"\nimport { clamp } from \"motion-utils\"\nimport { handOffElementState } from \"../animation/animate/element\"\nimport { GroupAnimation } from \"../animation/GroupAnimation\"\nimport type { AnimationOptions, Transition } from \"../animation/types\"\nimport { frameData, frameSteps } from \"../frameloop\"\nimport { microtask } from \"../frameloop/microtask\"\nimport { time } from \"../frameloop/sync-time\"\nimport { HTMLProjectionNode } from \"../projection/node/HTMLProjectionNode\"\nimport type { IProjectionNode } from \"../projection/node/types\"\nimport { HTMLVisualElement } from \"../render/html/HTMLVisualElement\"\nimport { visualElementStore } from \"../render/store\"\nimport { hasTransform } from \"../projection/utils/has-transform\"\nimport {\n resolveElements,\n type ElementOrSelector,\n} from \"../utils/resolve-elements\"\n\ntype LayoutAnimationScope = Element | Document\ntype LayoutBuilderResolve = (animation: GroupAnimation) => void\ntype LayoutBuilderReject = (error: unknown) => void\n\ninterface RestorePoint {\n parent: Element\n next: ChildNode | null\n}\n\nconst layoutSelector = \"[data-layout],[data-layout-id]\"\n\n/**\n * All imperatively-created projection nodes live in one persistent tree,\n * shared across animateLayout() calls (and with any React-created nodes,\n * via the singleton document root). Keyed by element for reuse.\n */\nconst layoutNodes = new WeakMap<Element, IProjectionNode>()\n\n/**\n * Builders created within the same synchronous tick are flushed together\n * as a single \"commit\": every node is snapshotted before any updateDom\n * runs, mirroring React batching renders from different parts of the tree.\n */\nlet pendingBuilders: LayoutAnimationBuilder[] | undefined\n\nfunction collectLayoutElements(scope: LayoutAnimationScope): HTMLElement[] {\n const elements: HTMLElement[] = []\n\n if (scope instanceof HTMLElement && scope.matches(layoutSelector)) {\n elements.push(scope)\n }\n\n scope.querySelectorAll(layoutSelector).forEach((element) => {\n if (element instanceof HTMLElement) elements.push(element)\n })\n\n return elements\n}\n\n/**\n * Process any work scheduled on the frameloop now. A previous animation\n * may have been seeked while paused (controls.time = x) without a frame\n * having rendered it - we must materialise that state into the DOM\n * before taking snapshots.\n */\nfunction flushPendingFrame() {\n if (frameData.isProcessing) return\n\n const now = time.now()\n frameData.delta = clamp(0, 1000 / 60, now - frameData.timestamp)\n frameData.timestamp = now\n frameData.isProcessing = true\n frameSteps.update.process(frameData)\n frameSteps.preRender.process(frameData)\n frameSteps.render.process(frameData)\n frameData.isProcessing = false\n}\n\nfunction getProjectionParent(element: Element): IProjectionNode | undefined {\n let ancestor = element.parentElement\n while (ancestor) {\n const node = layoutNodes.get(ancestor)\n if (node && node.instance) return node\n ancestor = ancestor.parentElement\n }\n return undefined\n}\n\nfunction createVisualElement() {\n return new HTMLVisualElement(\n {\n props: {},\n presenceContext: null,\n visualState: {\n latestValues: {},\n renderState: {\n transform: {},\n transformOrigin: {},\n style: {},\n vars: {},\n },\n },\n },\n { allowProjection: true }\n )\n}\n\nfunction readNodeOptions(element: HTMLElement, transition?: Transition) {\n const layoutAttr = element.getAttribute(\"data-layout\")\n const layoutId = element.getAttribute(\"data-layout-id\") ?? undefined\n\n return {\n layoutId,\n layout: layoutAttr !== null ? true : undefined,\n animationType: (!layoutAttr || layoutAttr === \"true\"\n ? \"both\"\n : layoutAttr) as \"both\",\n transition,\n }\n}\n\nfunction prepareNode(\n element: HTMLElement,\n transition?: Transition\n): IProjectionNode {\n let node = layoutNodes.get(element)\n\n if (!node) {\n let visualElement = visualElementStore.get(element) as\n | HTMLVisualElement\n | undefined\n\n if (!visualElement) {\n visualElement = createVisualElement()\n\n /**\n * Values animate() has been rendering on this element move to\n * the VisualElement, so the layout animation composes with\n * them instead of overwriting them.\n */\n handOffElementState(element, visualElement)\n }\n\n /**\n * A first-time element may carry a projection transform in its\n * inline style (e.g. it was cloned from an element mid-animation).\n * That transform isn't tracked in latestValues so the engine can't\n * reset it before measuring - clear it now so the first layout\n * measurement isn't inflated.\n */\n if (\n element.style.transform &&\n !hasTransform(visualElement.latestValues)\n ) {\n element.style.transform = \"\"\n }\n\n node = new HTMLProjectionNode(\n visualElement.latestValues,\n getProjectionParent(element)\n )\n visualElement.projection = node\n\n node.setOptions({\n ...readNodeOptions(element, transition),\n visualElement,\n })\n node.mount(element)\n layoutNodes.set(element, node)\n } else {\n node.setOptions(readNodeOptions(element, transition))\n }\n\n node.isPresent = true\n if (node.options.onExitComplete) {\n node.setOptions({ onExitComplete: undefined })\n }\n\n return node\n}\n\n/**\n * Get a projection node for an element, so imperative gestures like\n * drag() can measure its layout. Reuses a node owned by a `motion`\n * component or animateLayout(), otherwise creates one in the shared\n * imperative tree. Returns the node and a function that releases it.\n */\nexport function acquireProjectionNode(\n element: HTMLElement\n): [IProjectionNode, VoidFunction] {\n const owned =\n layoutNodes.get(element) || visualElementStore.get(element)?.projection\n\n /**\n * A VisualElement can outlive a node we released (e.g. a stopped\n * drag()), so only reuse a node that's still mounted.\n */\n if (owned?.instance) return [owned, () => {}]\n\n const node = prepareNode(element)\n\n return [\n node,\n () => layoutNodes.get(element) === node && dropNode(element, node),\n ]\n}\n\nfunction sortDocumentOrder(elements: Iterable<HTMLElement>) {\n return [...elements].sort((a, b) =>\n a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1\n )\n}\n\nfunction dropNode(element: Element, node: IProjectionNode) {\n node.setOptions({ onExitComplete: undefined })\n\n /**\n * Stop any lingering animation so it can't leak into future updates.\n * A follow node can share its currentAnimation with a surviving lead\n * (via resumingFrom), in which case it isn't ours to stop.\n */\n const stack = node.getStack()\n if (!stack || node.isLead()) node.currentAnimation?.stop()\n\n node.unmount()\n layoutNodes.delete(element)\n}\n\nfunction flushPendingBuilders() {\n const builders = pendingBuilders!\n pendingBuilders = undefined\n\n flushPendingFrame()\n\n /**\n * Discover and mount every node across all builders before snapshotting\n * any of them. Mounting during an active update flags isLayoutDirty,\n * which would make that node's own willUpdate skip its snapshot.\n * Document order guarantees ancestors mount before descendants, even\n * when they're discovered by different builders.\n */\n const targets = new Map<HTMLElement, LayoutAnimationBuilder[]>()\n for (const builder of builders) {\n for (const element of builder.collectTargets()) {\n const owners = targets.get(element)\n owners ? owners.push(builder) : targets.set(element, [builder])\n }\n }\n\n const union = new Map<HTMLElement, IProjectionNode>()\n for (const element of sortDocumentOrder(targets.keys())) {\n const owners = targets.get(element)!\n const node = prepareNode(\n element,\n owners[owners.length - 1].transitionFor(element)\n )\n for (const owner of owners) owner.adopt(element, node)\n union.set(element, node)\n }\n\n union.forEach((node) => {\n node.isLayoutDirty = false\n node.willUpdate()\n })\n\n const updatePromises: Promise<void>[] = []\n for (const builder of builders) {\n const result = builder.runUpdate()\n if (result) updatePromises.push(result)\n }\n\n const commit = () => {\n /**\n * Process all additions before any removals so that, even across\n * builders, a removed member knows whether a replacement with the\n * same layoutId was added in this commit.\n */\n const newMemberIds = new Set<string>()\n for (const builder of builders) {\n builder.reconcileAdditions(newMemberIds)\n }\n for (const builder of builders) {\n builder.reconcileRemovals(newMemberIds)\n }\n\n let root: IProjectionNode | undefined\n union.forEach((node) => (root ||= node.root))\n for (const builder of builders) root ||= builder.getRoot()\n\n root?.didUpdate()\n\n /**\n * The root flushes the update on a microtask, synchronously\n * processing the frame that creates the layout animations. Collect\n * them in a later microtask step of the same pass.\n */\n microtask.render(() => {\n for (const builder of builders) builder.finalize()\n })\n }\n\n updatePromises.length ? Promise.all(updatePromises).then(commit) : commit()\n}\n\nexport class LayoutAnimationBuilder {\n private sharedTransitions = new Map<string, AnimationOptions>()\n\n private notifyReady: LayoutBuilderResolve = () => {}\n private rejectReady: LayoutBuilderReject = () => {}\n private readyPromise: Promise<GroupAnimation>\n\n private tracked = new Map<HTMLElement, IProjectionNode>()\n private restorePoints = new Map<HTMLElement, RestorePoint>()\n private updateError: unknown\n\n constructor(\n private scope: LayoutAnimationScope,\n private updateDom: () => void | Promise<void>,\n private defaultOptions?: AnimationOptions\n ) {\n this.readyPromise = new Promise<GroupAnimation>((resolve, reject) => {\n this.notifyReady = resolve\n this.rejectReady = reject\n })\n\n if (!pendingBuilders) {\n pendingBuilders = []\n queueMicrotask(flushPendingBuilders)\n }\n pendingBuilders.push(this)\n }\n\n shared(id: string, transition: AnimationOptions): this {\n this.sharedTransitions.set(id, transition)\n return this\n }\n\n then(resolve: LayoutBuilderResolve, reject?: LayoutBuilderReject) {\n return this.readyPromise.then(resolve, reject)\n }\n\n transitionFor(element: HTMLElement): Transition | undefined {\n const layoutId = element.getAttribute(\"data-layout-id\")\n return ((layoutId && this.sharedTransitions.get(layoutId)) ||\n this.defaultOptions) as Transition | undefined\n }\n\n adopt(element: HTMLElement, node: IProjectionNode) {\n this.tracked.set(element, node)\n this.restorePoints.set(element, {\n parent: element.parentElement!,\n next: element.nextSibling,\n })\n }\n\n collectTargets() {\n return collectLayoutElements(this.scope)\n }\n\n runUpdate(): Promise<void> | undefined {\n try {\n const result = this.updateDom()\n if (result && typeof result.then === \"function\") {\n return result.then(undefined, (error: unknown) => {\n this.updateError = error\n })\n }\n } catch (error) {\n this.updateError = error\n }\n return undefined\n }\n\n reconcileAdditions(newMemberIds: Set<string>) {\n for (const element of collectLayoutElements(this.scope)) {\n if (this.tracked.has(element)) continue\n const node = prepareNode(element, this.transitionFor(element))\n this.adopt(element, node)\n node.options.layoutId && newMemberIds.add(node.options.layoutId)\n }\n }\n\n reconcileRemovals(newMemberIds: Set<string>) {\n this.tracked.forEach((node, element) => {\n if (element.isConnected) return\n\n const restore = this.restorePoints.get(element)\n this.restorePoints.delete(element)\n\n const { layoutId } = node.options\n const stack = node.getStack()\n const hasSurvivor =\n stack &&\n stack.members.some(\n (member) =>\n member !== node &&\n (member.instance as HTMLElement | undefined)\n ?.isConnected\n )\n\n /**\n * A removed lead with a surviving stack member - and no\n * replacement member added this commit - runs an exit\n * crossfade: restore the element to its old position in the\n * DOM, relegate it and let the survivor take over. It's\n * removed again once the animation completes.\n */\n if (\n layoutId &&\n node.isLead() &&\n hasSurvivor &&\n !newMemberIds.has(layoutId)\n ) {\n if (restore && restore.parent.isConnected) {\n restore.parent.insertBefore(\n element,\n restore.next && restore.next.parentNode === restore.parent\n ? restore.next\n : null\n )\n node.isPresent = false\n node.setOptions({\n onExitComplete: () => {\n element.remove()\n dropNode(element, node)\n },\n })\n if (node.relegate()) return\n\n element.remove()\n }\n }\n\n dropNode(element, node)\n this.tracked.delete(element)\n })\n }\n\n getRoot(): IProjectionNode | undefined {\n let root: IProjectionNode | undefined\n this.tracked.forEach((node) => (root ||= node.root))\n return root\n }\n\n finalize() {\n if (this.updateError) {\n this.rejectReady(this.updateError)\n return\n }\n\n const animations = new Set<GroupAnimation[\"animations\"][number]>()\n this.tracked.forEach((node) => {\n if (node.instance && node.currentAnimation) {\n animations.add(node.currentAnimation)\n }\n })\n\n this.notifyReady(new GroupAnimation([...animations]))\n }\n}\n\nexport function parseAnimateLayoutArgs(\n scopeOrUpdateDom: ElementOrSelector | (() => void),\n updateDomOrOptions?: (() => void) | AnimationOptions,\n options?: AnimationOptions\n): {\n scope: Element | Document\n updateDom: () => void\n defaultOptions?: AnimationOptions\n} {\n if (typeof scopeOrUpdateDom === \"function\") {\n return {\n scope: activeScope.current?.root || document,\n updateDom: scopeOrUpdateDom,\n defaultOptions: updateDomOrOptions as AnimationOptions | undefined,\n }\n }\n\n const scope =\n scopeOrUpdateDom instanceof Document\n ? scopeOrUpdateDom\n : resolveElements(scopeOrUpdateDom)[0] ?? document\n\n return {\n scope,\n updateDom: updateDomOrOptions as () => void,\n defaultOptions: options,\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,cAAc,GAAG,gCAAgC;AAEvD;;;;AAIG;AACH,MAAM,WAAW,GAAG,IAAI,OAAO,EAA4B;AAE3D;;;;AAIG;AACH,IAAI,eAAqD;AAEzD,SAAS,qBAAqB,CAAC,KAA2B,EAAA;IACtD,MAAM,QAAQ,GAAkB,EAAE;IAElC,IAAI,KAAK,YAAY,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;AAC/D,QAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;IACxB;IAEA,KAAK,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,KAAI;QACvD,IAAI,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AAS,EAAE,gBAAgB;AAC3B,YAAA,cAAc,EAAE,kBAAkD;SACrE;IACL;AAEA,IAAA,MAAM,KAAK,GACP,gBAAgB,YAAY;AACxB,UAAE;UACA,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ;IAE1D,OAAO;QACH,KAAK;AACL,QAAA,SAAS,EAAE,kBAAgC;AAC3C,QAAA,cAAc,EAAE,OAAO;KAC1B;AACL;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { activeScope, addBuilderToScope } from '../scope/active.mjs';
|
|
1
2
|
import { parseAnimateLayoutArgs, LayoutAnimationBuilder } from './LayoutAnimationBuilder.mjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -12,7 +13,12 @@ import { parseAnimateLayoutArgs, LayoutAnimationBuilder } from './LayoutAnimatio
|
|
|
12
13
|
*/
|
|
13
14
|
function animateLayout(scopeOrUpdateDom, updateDomOrOptions, options) {
|
|
14
15
|
const { scope, updateDom, defaultOptions } = parseAnimateLayoutArgs(scopeOrUpdateDom, updateDomOrOptions, options);
|
|
15
|
-
|
|
16
|
+
const builder = new LayoutAnimationBuilder(scope, updateDom, {
|
|
17
|
+
...activeScope.current?.transition,
|
|
18
|
+
...defaultOptions,
|
|
19
|
+
});
|
|
20
|
+
addBuilderToScope(builder);
|
|
21
|
+
return builder;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
export { animateLayout };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animate-layout.mjs","sources":["../../../src/layout/animate-layout.ts"],"sourcesContent":["import type { AnimationOptions } from \"../animation/types\"\nimport type { ElementOrSelector } from \"../utils/resolve-elements\"\nimport {\n LayoutAnimationBuilder,\n parseAnimateLayoutArgs,\n} from \"./LayoutAnimationBuilder\"\n\n/**\n * Animate layout changes made within `updateDom` on elements tagged\n * with `data-layout` or `data-layout-id`.\n *\n * ```\n * animateLayout(() => {\n * element.style.justifyContent = \"flex-end\"\n * })\n * ```\n */\nexport function animateLayout(\n scopeOrUpdateDom: ElementOrSelector | (() => void),\n updateDomOrOptions?: (() => void) | AnimationOptions,\n options?: AnimationOptions\n): LayoutAnimationBuilder {\n const { scope, updateDom, defaultOptions } = parseAnimateLayoutArgs(\n scopeOrUpdateDom,\n updateDomOrOptions,\n options\n )\n
|
|
1
|
+
{"version":3,"file":"animate-layout.mjs","sources":["../../../src/layout/animate-layout.ts"],"sourcesContent":["import type { AnimationOptions } from \"../animation/types\"\nimport { activeScope, addBuilderToScope } from \"../scope/active\"\nimport type { ElementOrSelector } from \"../utils/resolve-elements\"\nimport {\n LayoutAnimationBuilder,\n parseAnimateLayoutArgs,\n} from \"./LayoutAnimationBuilder\"\n\n/**\n * Animate layout changes made within `updateDom` on elements tagged\n * with `data-layout` or `data-layout-id`.\n *\n * ```\n * animateLayout(() => {\n * element.style.justifyContent = \"flex-end\"\n * })\n * ```\n */\nexport function animateLayout(\n scopeOrUpdateDom: ElementOrSelector | (() => void),\n updateDomOrOptions?: (() => void) | AnimationOptions,\n options?: AnimationOptions\n): LayoutAnimationBuilder {\n const { scope, updateDom, defaultOptions } = parseAnimateLayoutArgs(\n scopeOrUpdateDom,\n updateDomOrOptions,\n options\n )\n const builder = new LayoutAnimationBuilder(scope, updateDom, {\n ...activeScope.current?.transition,\n ...defaultOptions,\n })\n addBuilderToScope(builder)\n return builder\n}\n"],"names":[],"mappings":";;;AAQA;;;;;;;;;AASG;SACa,aAAa,CACzB,gBAAkD,EAClD,kBAAoD,EACpD,OAA0B,EAAA;AAE1B,IAAA,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,GAAG,sBAAsB,CAC/D,gBAAgB,EAChB,kBAAkB,EAClB,OAAO,CACV;IACD,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC,KAAK,EAAE,SAAS,EAAE;AACzD,QAAA,GAAG,WAAW,CAAC,OAAO,EAAE,UAAU;AAClC,QAAA,GAAG,cAAc;AACpB,KAAA,CAAC;IACF,iBAAiB,CAAC,OAAO,CAAC;AAC1B,IAAA,OAAO,OAAO;AAClB;;;;"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { addDomEvent } from '../../events/add-dom-event.mjs';
|
|
2
2
|
import { createProjectionNode } from './create-projection-node.mjs';
|
|
3
3
|
|
|
4
|
-
const DocumentProjectionNode =
|
|
4
|
+
const DocumentProjectionNode =
|
|
5
|
+
/* @__PURE__ */ createProjectionNode({
|
|
5
6
|
attachResizeListener: (ref, notify) => addDomEvent(ref, "resize", notify),
|
|
6
7
|
measureScroll: () => ({
|
|
7
|
-
x: document.documentElement.scrollLeft ||
|
|
8
|
-
|
|
8
|
+
x: document.documentElement.scrollLeft ||
|
|
9
|
+
document.body?.scrollLeft ||
|
|
10
|
+
0,
|
|
11
|
+
y: document.documentElement.scrollTop ||
|
|
12
|
+
document.body?.scrollTop ||
|
|
13
|
+
0,
|
|
9
14
|
}),
|
|
10
15
|
checkIsScrollRoot: () => true,
|
|
11
16
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentProjectionNode.mjs","sources":["../../../../src/projection/node/DocumentProjectionNode.ts"],"sourcesContent":["import { addDomEvent } from \"../../events/add-dom-event\"\nimport { createProjectionNode } from \"./create-projection-node\"\n\nexport const DocumentProjectionNode
|
|
1
|
+
{"version":3,"file":"DocumentProjectionNode.mjs","sources":["../../../../src/projection/node/DocumentProjectionNode.ts"],"sourcesContent":["import { addDomEvent } from \"../../events/add-dom-event\"\nimport { createProjectionNode } from \"./create-projection-node\"\n\nexport const DocumentProjectionNode =\n /* @__PURE__ */ createProjectionNode<Window>({\n attachResizeListener: (\n ref: Window | Element,\n notify: VoidFunction\n ): VoidFunction => addDomEvent(ref, \"resize\", notify),\n measureScroll: () => ({\n x:\n document.documentElement.scrollLeft ||\n document.body?.scrollLeft ||\n 0,\n y:\n document.documentElement.scrollTop ||\n document.body?.scrollTop ||\n 0,\n }),\n checkIsScrollRoot: () => true,\n })\n"],"names":[],"mappings":";;;MAGa,sBAAsB;AAC/B,gBAAgB,oBAAoB,CAAS;AACzC,IAAA,oBAAoB,EAAE,CAClB,GAAqB,EACrB,MAAoB,KACL,WAAW,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC;AACrD,IAAA,aAAa,EAAE,OAAO;AAClB,QAAA,CAAC,EACG,QAAQ,CAAC,eAAe,CAAC,UAAU;YACnC,QAAQ,CAAC,IAAI,EAAE,UAAU;YACzB,CAAC;AACL,QAAA,CAAC,EACG,QAAQ,CAAC,eAAe,CAAC,SAAS;YAClC,QAAQ,CAAC,IAAI,EAAE,SAAS;YACxB,CAAC;KACR,CAAC;AACF,IAAA,iBAAiB,EAAE,MAAM,IAAI;AAChC,CAAA;;;;"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { createProjectionNode } from './create-projection-node.mjs';
|
|
2
2
|
import { DocumentProjectionNode } from './DocumentProjectionNode.mjs';
|
|
3
|
+
import { rootProjectionNode } from './root.mjs';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
const HTMLProjectionNode = createProjectionNode({
|
|
5
|
+
const HTMLProjectionNode =
|
|
6
|
+
/* @__PURE__ */ createProjectionNode({
|
|
8
7
|
measureScroll: (instance) => ({
|
|
9
8
|
x: instance.scrollLeft,
|
|
10
9
|
y: instance.scrollTop,
|
|
@@ -24,5 +23,5 @@ const HTMLProjectionNode = createProjectionNode({
|
|
|
24
23
|
checkIsScrollRoot: (instance) => Boolean(window.getComputedStyle(instance).position === "fixed"),
|
|
25
24
|
});
|
|
26
25
|
|
|
27
|
-
export { HTMLProjectionNode
|
|
26
|
+
export { HTMLProjectionNode };
|
|
28
27
|
//# sourceMappingURL=HTMLProjectionNode.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTMLProjectionNode.mjs","sources":["../../../../src/projection/node/HTMLProjectionNode.ts"],"sourcesContent":["import { createProjectionNode } from \"./create-projection-node\"\nimport { DocumentProjectionNode } from \"./DocumentProjectionNode\"\nimport {
|
|
1
|
+
{"version":3,"file":"HTMLProjectionNode.mjs","sources":["../../../../src/projection/node/HTMLProjectionNode.ts"],"sourcesContent":["import { createProjectionNode } from \"./create-projection-node\"\nimport { DocumentProjectionNode } from \"./DocumentProjectionNode\"\nimport { rootProjectionNode } from \"./root\"\n\nexport const HTMLProjectionNode =\n /* @__PURE__ */ createProjectionNode<HTMLElement>({\n measureScroll: (instance) => ({\n x: instance.scrollLeft,\n y: instance.scrollTop,\n }),\n defaultParent: () => {\n if (!rootProjectionNode.current) {\n const documentNode = new DocumentProjectionNode({})\n documentNode.mount(window)\n documentNode.setOptions({ layoutScroll: true })\n rootProjectionNode.current = documentNode\n }\n return rootProjectionNode.current\n },\n resetTransform: (instance, value) => {\n instance.style.transform = value !== undefined ? value : \"none\"\n },\n checkIsScrollRoot: (instance) =>\n Boolean(window.getComputedStyle(instance).position === \"fixed\"),\n })\n"],"names":[],"mappings":";;;;MAIa,kBAAkB;AAC3B,gBAAgB,oBAAoB,CAAc;AAC9C,IAAA,aAAa,EAAE,CAAC,QAAQ,MAAM;QAC1B,CAAC,EAAE,QAAQ,CAAC,UAAU;QACtB,CAAC,EAAE,QAAQ,CAAC,SAAS;KACxB,CAAC;IACF,aAAa,EAAE,MAAK;AAChB,QAAA,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE;AAC7B,YAAA,MAAM,YAAY,GAAG,IAAI,sBAAsB,CAAC,EAAE,CAAC;AACnD,YAAA,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC;YAC1B,YAAY,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AAC/C,YAAA,kBAAkB,CAAC,OAAO,GAAG,YAAY;QAC7C;QACA,OAAO,kBAAkB,CAAC,OAAO;IACrC,CAAC;AACD,IAAA,cAAc,EAAE,CAAC,QAAQ,EAAE,KAAK,KAAI;AAChC,QAAA,QAAQ,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,KAAK,SAAS,GAAG,KAAK,GAAG,MAAM;IACnE,CAAC;AACD,IAAA,iBAAiB,EAAE,CAAC,QAAQ,KACxB,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC;AACtE,CAAA;;;;"}
|
|
@@ -31,14 +31,6 @@ import { globalProjectionState } from './state.mjs';
|
|
|
31
31
|
import { frame, cancelFrame, frameSteps } from '../../frameloop/frame.mjs';
|
|
32
32
|
import { frameData } from '../../frameloop/frame-data.mjs';
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* Correctors registered via addScaleCorrector before projection loaded
|
|
36
|
-
* (e.g. with an async LazyMotion bundle) take precedence over the defaults.
|
|
37
|
-
*/
|
|
38
|
-
Object.assign(scaleCorrectors, {
|
|
39
|
-
...defaultScaleCorrectors,
|
|
40
|
-
...scaleCorrectors,
|
|
41
|
-
});
|
|
42
34
|
const metrics = {
|
|
43
35
|
nodes: 0,
|
|
44
36
|
calculatedTargetDeltas: 0,
|
|
@@ -81,6 +73,16 @@ function cancelTreeOptimisedTransformAnimations(projectionNode) {
|
|
|
81
73
|
}
|
|
82
74
|
}
|
|
83
75
|
function createProjectionNode({ attachResizeListener, defaultParent, measureScroll, checkIsScrollRoot, resetTransform, }) {
|
|
76
|
+
/**
|
|
77
|
+
* Correctors registered via addScaleCorrector before projection loaded
|
|
78
|
+
* (e.g. with an async LazyMotion bundle) take precedence over the defaults.
|
|
79
|
+
* Applied here rather than at module scope so bundlers can drop projection
|
|
80
|
+
* when it's unused.
|
|
81
|
+
*/
|
|
82
|
+
Object.assign(scaleCorrectors, {
|
|
83
|
+
...defaultScaleCorrectors,
|
|
84
|
+
...scaleCorrectors,
|
|
85
|
+
});
|
|
84
86
|
return class ProjectionNode {
|
|
85
87
|
constructor(latestValues = {}, parent = defaultParent?.()) {
|
|
86
88
|
/**
|
|
@@ -737,7 +739,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
737
739
|
}
|
|
738
740
|
return boxWithoutScroll;
|
|
739
741
|
}
|
|
740
|
-
applyTransform(box, transformOnly = false, output) {
|
|
742
|
+
applyTransform(box, transformOnly = false, output, skipOwnTransform) {
|
|
741
743
|
const withTransforms = output || createBox();
|
|
742
744
|
copyBoxInto(withTransforms, box);
|
|
743
745
|
for (let i = 0; i < this.path.length; i++) {
|
|
@@ -753,7 +755,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
753
755
|
continue;
|
|
754
756
|
transformBox(withTransforms, node.latestValues, node.layout?.layoutBox);
|
|
755
757
|
}
|
|
756
|
-
if (hasTransform(this.latestValues)) {
|
|
758
|
+
if (!skipOwnTransform && hasTransform(this.latestValues)) {
|
|
757
759
|
transformBox(withTransforms, this.latestValues, this.layout?.layoutBox);
|
|
758
760
|
}
|
|
759
761
|
return withTransforms;
|
|
@@ -888,7 +890,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
888
890
|
}
|
|
889
891
|
else if (this.targetDelta) {
|
|
890
892
|
if (Boolean(this.resumingFrom)) {
|
|
891
|
-
|
|
893
|
+
/**
|
|
894
|
+
* Own transforms are applied later, in applyTransformsToTarget,
|
|
895
|
+
* so only apply ancestor transforms here or they'd be doubled.
|
|
896
|
+
*/
|
|
897
|
+
this.applyTransform(this.layout.layoutBox, false, this.target, true);
|
|
892
898
|
}
|
|
893
899
|
else {
|
|
894
900
|
copyBoxInto(this.target, this.layout.layoutBox);
|
|
@@ -1657,10 +1663,13 @@ function clearIsLayoutDirty(node) {
|
|
|
1657
1663
|
* A dragged node doesn't layout animate, so it jumps to its new layout. Shift
|
|
1658
1664
|
* its descendants' snapshots by the same amount, so they only animate layout
|
|
1659
1665
|
* changes relative to it, rather than lagging behind.
|
|
1666
|
+
*
|
|
1667
|
+
* If its drag ended since the snapshot (e.g. drag disabled from onDrag), it
|
|
1668
|
+
* layout animates again, so its descendants mustn't follow its jump.
|
|
1660
1669
|
*/
|
|
1661
1670
|
function followDraggedAncestor(node) {
|
|
1662
1671
|
const { snapshot, dragAncestor } = node;
|
|
1663
|
-
const to = dragAncestor?.layout;
|
|
1672
|
+
const to = dragAncestor?.isAnimationBlocked && dragAncestor.layout;
|
|
1664
1673
|
if (!snapshot || !to || node.resumeFrom || node.isAnimationBlocked)
|
|
1665
1674
|
return;
|
|
1666
1675
|
const from = dragAncestor.dragSnapshot;
|