motion-dom 12.36.0 → 12.38.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.
Files changed (35) hide show
  1. package/dist/cjs/index.js +179 -83
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/animation/AsyncMotionValueAnimation.mjs +15 -6
  4. package/dist/es/animation/AsyncMotionValueAnimation.mjs.map +1 -1
  5. package/dist/es/animation/JSAnimation.mjs +16 -3
  6. package/dist/es/animation/JSAnimation.mjs.map +1 -1
  7. package/dist/es/animation/interfaces/motion-value.mjs +1 -1
  8. package/dist/es/animation/interfaces/motion-value.mjs.map +1 -1
  9. package/dist/es/animation/interfaces/visual-element-target.mjs +4 -1
  10. package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
  11. package/dist/es/animation/utils/active-animations.mjs +5 -2
  12. package/dist/es/animation/utils/active-animations.mjs.map +1 -1
  13. package/dist/es/animation/utils/is-transition-defined.mjs +18 -2
  14. package/dist/es/animation/utils/is-transition-defined.mjs.map +1 -1
  15. package/dist/es/animation/waapi/supports/waapi.mjs +21 -12
  16. package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
  17. package/dist/es/animation/waapi/utils/is-browser-color.mjs +13 -0
  18. package/dist/es/animation/waapi/utils/is-browser-color.mjs.map +1 -0
  19. package/dist/es/index.mjs +1 -1
  20. package/dist/es/projection/animation/mix-values.mjs +8 -3
  21. package/dist/es/projection/animation/mix-values.mjs.map +1 -1
  22. package/dist/es/projection/geometry/delta-apply.mjs +4 -6
  23. package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
  24. package/dist/es/projection/geometry/delta-calc.mjs +16 -10
  25. package/dist/es/projection/geometry/delta-calc.mjs.map +1 -1
  26. package/dist/es/projection/node/create-projection-node.mjs +49 -16
  27. package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
  28. package/dist/es/value/follow-value.mjs +3 -0
  29. package/dist/es/value/follow-value.mjs.map +1 -1
  30. package/dist/index.d.ts +30 -11
  31. package/dist/motion-dom.dev.js +179 -83
  32. package/dist/motion-dom.js +1 -1
  33. package/package.json +2 -2
  34. package/dist/es/animation/utils/get-final-keyframe.mjs +0 -13
  35. package/dist/es/animation/utils/get-final-keyframe.mjs.map +0 -1
@@ -65,10 +65,8 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
65
65
  node.options.layoutScroll &&
66
66
  node.scroll &&
67
67
  node !== node.root) {
68
- transformBox(box, {
69
- x: -node.scroll.offset.x,
70
- y: -node.scroll.offset.y,
71
- });
68
+ translateAxis(box.x, -node.scroll.offset.x);
69
+ translateAxis(box.y, -node.scroll.offset.y);
72
70
  }
73
71
  if (delta) {
74
72
  // Incoporate each ancestor's scale into a cumulative treeScale for this component
@@ -95,8 +93,8 @@ function applyTreeDeltas(box, treeScale, treePath, isSharedTransition = false) {
95
93
  }
96
94
  }
97
95
  function translateAxis(axis, distance) {
98
- axis.min = axis.min + distance;
99
- axis.max = axis.max + distance;
96
+ axis.min += distance;
97
+ axis.max += distance;
100
98
  }
101
99
  /**
102
100
  * Apply a transform to an axis from the latest resolved motion values.
@@ -1 +1 @@
1
- {"version":3,"file":"delta-apply.mjs","sources":["../../../../src/projection/geometry/delta-apply.ts"],"sourcesContent":["import { Axis, Box, Delta, Point } from \"motion-utils\"\nimport { mixNumber } from \"../../utils/mix/number\"\nimport { ResolvedValues } from \"../../render/types\"\nimport { hasTransform } from \"../utils/has-transform\"\n\n/**\n * Scales a point based on a factor and an originPoint\n */\nexport function scalePoint(point: number, scale: number, originPoint: number) {\n const distanceFromOrigin = point - originPoint\n const scaled = scale * distanceFromOrigin\n return originPoint + scaled\n}\n\n/**\n * Applies a translate/scale delta to a point\n */\nexport function applyPointDelta(\n point: number,\n translate: number,\n scale: number,\n originPoint: number,\n boxScale?: number\n): number {\n if (boxScale !== undefined) {\n point = scalePoint(point, boxScale, originPoint)\n }\n\n return scalePoint(point, scale, originPoint) + translate\n}\n\n/**\n * Applies a translate/scale delta to an axis\n */\nexport function applyAxisDelta(\n axis: Axis,\n translate: number = 0,\n scale: number = 1,\n originPoint: number,\n boxScale?: number\n): void {\n axis.min = applyPointDelta(\n axis.min,\n translate,\n scale,\n originPoint,\n boxScale\n )\n\n axis.max = applyPointDelta(\n axis.max,\n translate,\n scale,\n originPoint,\n boxScale\n )\n}\n\n/**\n * Applies a translate/scale delta to a box\n */\nexport function applyBoxDelta(box: Box, { x, y }: Delta): void {\n applyAxisDelta(box.x, x.translate, x.scale, x.originPoint)\n applyAxisDelta(box.y, y.translate, y.scale, y.originPoint)\n}\n\nconst TREE_SCALE_SNAP_MIN = 0.999999999999\nconst TREE_SCALE_SNAP_MAX = 1.0000000000001\n\n/**\n * Apply a tree of deltas to a box. We do this to calculate the effect of all the transforms\n * in a tree upon our box before then calculating how to project it into our desired viewport-relative box\n *\n * This is the final nested loop within updateLayoutDelta for future refactoring\n */\nexport function applyTreeDeltas(\n box: Box,\n treeScale: Point,\n treePath: any[],\n isSharedTransition: boolean = false\n) {\n const treeLength = treePath.length\n if (!treeLength) return\n\n // Reset the treeScale\n treeScale.x = treeScale.y = 1\n\n let node: any\n let delta: Delta | undefined\n\n for (let i = 0; i < treeLength; i++) {\n node = treePath[i]\n delta = node.projectionDelta\n\n /**\n * TODO: Prefer to remove this, but currently we have motion components with\n * display: contents in Framer.\n */\n const { visualElement } = node.options\n if (\n visualElement &&\n visualElement.props.style &&\n visualElement.props.style.display === \"contents\"\n ) {\n continue\n }\n\n if (\n isSharedTransition &&\n node.options.layoutScroll &&\n node.scroll &&\n node !== node.root\n ) {\n transformBox(box, {\n x: -node.scroll.offset.x,\n y: -node.scroll.offset.y,\n })\n }\n\n if (delta) {\n // Incoporate each ancestor's scale into a cumulative treeScale for this component\n treeScale.x *= delta.x.scale\n treeScale.y *= delta.y.scale\n\n // Apply each ancestor's calculated delta into this component's recorded layout box\n applyBoxDelta(box, delta)\n }\n\n if (isSharedTransition && hasTransform(node.latestValues)) {\n transformBox(box, node.latestValues, node.layout?.layoutBox)\n }\n }\n\n /**\n * Snap tree scale back to 1 if it's within a non-perceivable threshold.\n * This will help reduce useless scales getting rendered.\n */\n if (\n treeScale.x < TREE_SCALE_SNAP_MAX &&\n treeScale.x > TREE_SCALE_SNAP_MIN\n ) {\n treeScale.x = 1.0\n }\n if (\n treeScale.y < TREE_SCALE_SNAP_MAX &&\n treeScale.y > TREE_SCALE_SNAP_MIN\n ) {\n treeScale.y = 1.0\n }\n}\n\nexport function translateAxis(axis: Axis, distance: number) {\n axis.min = axis.min + distance\n axis.max = axis.max + distance\n}\n\n/**\n * Apply a transform to an axis from the latest resolved motion values.\n * This function basically acts as a bridge between a flat motion value map\n * and applyAxisDelta\n */\nexport function transformAxis(\n axis: Axis,\n axisTranslate?: number,\n axisScale?: number,\n boxScale?: number,\n axisOrigin: number = 0.5\n): void {\n const originPoint = mixNumber(axis.min, axis.max, axisOrigin)\n\n // Apply the axis delta to the final axis\n applyAxisDelta(axis, axisTranslate, axisScale, originPoint, boxScale)\n}\n\nfunction resolveAxisTranslate(\n value: number | string | undefined,\n axis: Axis\n): number | undefined {\n if (typeof value === \"string\") {\n return (parseFloat(value) / 100) * (axis.max - axis.min)\n }\n return value as number | undefined\n}\n\n/**\n * Apply a transform to a box from the latest resolved motion values.\n */\nexport function transformBox(\n box: Box,\n transform: ResolvedValues,\n sourceBox?: Box\n) {\n const resolveBox = sourceBox ?? box\n transformAxis(\n box.x,\n resolveAxisTranslate(transform.x, resolveBox.x),\n transform.scaleX as number,\n transform.scale as number,\n transform.originX as number\n )\n transformAxis(\n box.y,\n resolveAxisTranslate(transform.y, resolveBox.y),\n transform.scaleY as number,\n transform.scale as number,\n transform.originY as number\n )\n}\n"],"names":[],"mappings":";;;AAKA;;AAEG;SACa,UAAU,CAAC,KAAa,EAAE,KAAa,EAAE,WAAmB,EAAA;AACxE,IAAA,MAAM,kBAAkB,GAAG,KAAK,GAAG,WAAW;AAC9C,IAAA,MAAM,MAAM,GAAG,KA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,CACT,GAAG,CAAC,CAAC,EACL,oBAAoB,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAC/C,SAAS,CAAC,MAAgB,EAC1B,SAAS,CAAC,KAAe,EACzB,SAAS,CAAC,OAAiB,CAC9B;AACD,IAAA,aAAa,CACT,GAAG,CAAC,CAAC,EACL,oBAAoB,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAC/C,SAAS,CAAC,MAAgB,EAC1B,SAAS,CAAC,KAAe,EACzB,SAAS,CAAC,OAAiB,CAC9B;AACL;;;;"}
1
+ {"version":3,"file":"delta-apply.mjs","sources":["../../../../src/projection/geometry/delta-apply.ts"],"sourcesContent":["import { Axis, Box, Delta, Point } from \"motion-utils\"\nimport { mixNumber } from \"../../utils/mix/number\"\nimport { ResolvedValues } from \"../../render/types\"\nimport { hasTransform } from \"../utils/has-transform\"\n\n/**\n * Scales a point based on a factor and an originPoint\n */\nexport function scalePoint(point: number, scale: number, originPoint: number) {\n const distanceFromOrigin = point - originPoint\n const scaled = scale * distanceFromOrigin\n return originPoint + scaled\n}\n\n/**\n * Applies a translate/scale delta to a point\n */\nexport function applyPointDelta(\n point: number,\n translate: number,\n scale: number,\n originPoint: number,\n boxScale?: number\n): number {\n if (boxScale !== undefined) {\n point = scalePoint(point, boxScale, originPoint)\n }\n\n return scalePoint(point, scale, originPoint) + translate\n}\n\n/**\n * Applies a translate/scale delta to an axis\n */\nexport function applyAxisDelta(\n axis: Axis,\n translate: number = 0,\n scale: number = 1,\n originPoint: number,\n boxScale?: number\n): void {\n axis.min = applyPointDelta(\n axis.min,\n translate,\n scale,\n originPoint,\n boxScale\n )\n\n axis.max = applyPointDelta(\n axis.max,\n translate,\n scale,\n originPoint,\n boxScale\n )\n}\n\n/**\n * Applies a translate/scale delta to a box\n */\nexport function applyBoxDelta(box: Box, { x, y }: Delta): void {\n applyAxisDelta(box.x, x.translate, x.scale, x.originPoint)\n applyAxisDelta(box.y, y.translate, y.scale, y.originPoint)\n}\n\nconst TREE_SCALE_SNAP_MIN = 0.999999999999\nconst TREE_SCALE_SNAP_MAX = 1.0000000000001\n\n/**\n * Apply a tree of deltas to a box. We do this to calculate the effect of all the transforms\n * in a tree upon our box before then calculating how to project it into our desired viewport-relative box\n *\n * This is the final nested loop within updateLayoutDelta for future refactoring\n */\nexport function applyTreeDeltas(\n box: Box,\n treeScale: Point,\n treePath: any[],\n isSharedTransition: boolean = false\n) {\n const treeLength = treePath.length\n if (!treeLength) return\n\n // Reset the treeScale\n treeScale.x = treeScale.y = 1\n\n let node: any\n let delta: Delta | undefined\n\n for (let i = 0; i < treeLength; i++) {\n node = treePath[i]\n delta = node.projectionDelta\n\n /**\n * TODO: Prefer to remove this, but currently we have motion components with\n * display: contents in Framer.\n */\n const { visualElement } = node.options\n if (\n visualElement &&\n visualElement.props.style &&\n visualElement.props.style.display === \"contents\"\n ) {\n continue\n }\n\n if (\n isSharedTransition &&\n node.options.layoutScroll &&\n node.scroll &&\n node !== node.root\n ) {\n translateAxis(box.x, -node.scroll.offset.x)\n translateAxis(box.y, -node.scroll.offset.y)\n }\n\n if (delta) {\n // Incoporate each ancestor's scale into a cumulative treeScale for this component\n treeScale.x *= delta.x.scale\n treeScale.y *= delta.y.scale\n\n // Apply each ancestor's calculated delta into this component's recorded layout box\n applyBoxDelta(box, delta)\n }\n\n if (isSharedTransition && hasTransform(node.latestValues)) {\n transformBox(box, node.latestValues, node.layout?.layoutBox)\n }\n }\n\n /**\n * Snap tree scale back to 1 if it's within a non-perceivable threshold.\n * This will help reduce useless scales getting rendered.\n */\n if (\n treeScale.x < TREE_SCALE_SNAP_MAX &&\n treeScale.x > TREE_SCALE_SNAP_MIN\n ) {\n treeScale.x = 1.0\n }\n if (\n treeScale.y < TREE_SCALE_SNAP_MAX &&\n treeScale.y > TREE_SCALE_SNAP_MIN\n ) {\n treeScale.y = 1.0\n }\n}\n\nexport function translateAxis(axis: Axis, distance: number) {\n axis.min += distance\n axis.max += distance\n}\n\n/**\n * Apply a transform to an axis from the latest resolved motion values.\n * This function basically acts as a bridge between a flat motion value map\n * and applyAxisDelta\n */\nexport function transformAxis(\n axis: Axis,\n axisTranslate?: number,\n axisScale?: number,\n boxScale?: number,\n axisOrigin: number = 0.5\n): void {\n const originPoint = mixNumber(axis.min, axis.max, axisOrigin)\n\n // Apply the axis delta to the final axis\n applyAxisDelta(axis, axisTranslate, axisScale, originPoint, boxScale)\n}\n\nfunction resolveAxisTranslate(\n value: number | string | undefined,\n axis: Axis\n): number | undefined {\n if (typeof value === \"string\") {\n return (parseFloat(value) / 100) * (axis.max - axis.min)\n }\n return value as number | undefined\n}\n\n/**\n * Apply a transform to a box from the latest resolved motion values.\n */\nexport function transformBox(\n box: Box,\n transform: ResolvedValues,\n sourceBox?: Box\n) {\n const resolveBox = sourceBox ?? box\n transformAxis(\n box.x,\n resolveAxisTranslate(transform.x, resolveBox.x),\n transform.scaleX as number,\n transform.scale as number,\n transform.originX as number\n )\n transformAxis(\n box.y,\n resolveAxisTranslate(transform.y, resolveBox.y),\n transform.scaleY as number,\n transform.scale as number,\n transform.originY as number\n )\n}\n"],"names":[],"mappings":";;;AAKA;;AAEG;SACa,UAAU,CAAC,KAAa,EAAE,KAAa,EAAE,WAAmB,EAAA;AACxE,IAAA,MAAM,kBAAkB,GAAG,KAAK,GAAG,WAAW;AAC9C,IAAA,MAAM,MAAM,GAAG,KAAK,GAAG,kBAAkB;IACzC,OAAO,WAAW,GAAG,MAAM;AAC/B;AAEA;;AAEG;AACG,SAAU,eAAe,CAC3B,KAAa,EACb,SAAiB,EACjB,KAAa,EACb,WAAmB,EACnB,QAAiB,EAAA;AAEjB,IAAA,IAAI,QAAQ,KAAK,SAAS,EAAE;QACxB,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC;IACpD;IAEA,OAAO,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,SAAS;AA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,CAC9B;AACL;;;;"}
@@ -32,21 +32,27 @@ function calcBoxDelta(delta, source, target, origin) {
32
32
  calcAxisDelta(delta.x, source.x, target.x, origin ? origin.originX : undefined);
33
33
  calcAxisDelta(delta.y, source.y, target.y, origin ? origin.originY : undefined);
34
34
  }
35
- function calcRelativeAxis(target, relative, parent) {
36
- target.min = parent.min + relative.min;
35
+ function calcRelativeAxis(target, relative, parent, anchor = 0) {
36
+ const anchorPoint = anchor
37
+ ? mixNumber(parent.min, parent.max, anchor)
38
+ : parent.min;
39
+ target.min = anchorPoint + relative.min;
37
40
  target.max = target.min + calcLength(relative);
38
41
  }
39
- function calcRelativeBox(target, relative, parent) {
40
- calcRelativeAxis(target.x, relative.x, parent.x);
41
- calcRelativeAxis(target.y, relative.y, parent.y);
42
+ function calcRelativeBox(target, relative, parent, anchor) {
43
+ calcRelativeAxis(target.x, relative.x, parent.x, anchor?.x);
44
+ calcRelativeAxis(target.y, relative.y, parent.y, anchor?.y);
42
45
  }
43
- function calcRelativeAxisPosition(target, layout, parent) {
44
- target.min = layout.min - parent.min;
46
+ function calcRelativeAxisPosition(target, layout, parent, anchor = 0) {
47
+ const anchorPoint = anchor
48
+ ? mixNumber(parent.min, parent.max, anchor)
49
+ : parent.min;
50
+ target.min = layout.min - anchorPoint;
45
51
  target.max = target.min + calcLength(layout);
46
52
  }
47
- function calcRelativePosition(target, layout, parent) {
48
- calcRelativeAxisPosition(target.x, layout.x, parent.x);
49
- calcRelativeAxisPosition(target.y, layout.y, parent.y);
53
+ function calcRelativePosition(target, layout, parent, anchor) {
54
+ calcRelativeAxisPosition(target.x, layout.x, parent.x, anchor?.x);
55
+ calcRelativeAxisPosition(target.y, layout.y, parent.y, anchor?.y);
50
56
  }
51
57
 
52
58
  export { calcAxisDelta, calcBoxDelta, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, isNear };
@@ -1 +1 @@
1
- {"version":3,"file":"delta-calc.mjs","sources":["../../../../src/projection/geometry/delta-calc.ts"],"sourcesContent":["import { Axis, AxisDelta, Box, Delta } from \"motion-utils\"\nimport { mixNumber } from \"../../utils/mix/number\"\nimport { ResolvedValues } from \"../../render/types\"\n\nconst SCALE_PRECISION = 0.0001\nconst SCALE_MIN = 1 - SCALE_PRECISION\nconst SCALE_MAX = 1 + SCALE_PRECISION\nconst TRANSLATE_PRECISION = 0.01\nconst TRANSLATE_MIN = 0 - TRANSLATE_PRECISION\nconst TRANSLATE_MAX = 0 + TRANSLATE_PRECISION\n\nexport function calcLength(axis: Axis) {\n return axis.max - axis.min\n}\n\nexport function isNear(\n value: number,\n target: number,\n maxDistance: number\n): boolean {\n return Math.abs(value - target) <= maxDistance\n}\n\nexport function calcAxisDelta(\n delta: AxisDelta,\n source: Axis,\n target: Axis,\n origin: number = 0.5\n) {\n delta.origin = origin\n delta.originPoint = mixNumber(source.min, source.max, delta.origin)\n delta.scale = calcLength(target) / calcLength(source)\n delta.translate =\n mixNumber(target.min, target.max, delta.origin) - delta.originPoint\n\n if (\n (delta.scale >= SCALE_MIN && delta.scale <= SCALE_MAX) ||\n isNaN(delta.scale)\n ) {\n delta.scale = 1.0\n }\n\n if (\n (delta.translate >= TRANSLATE_MIN &&\n delta.translate <= TRANSLATE_MAX) ||\n isNaN(delta.translate)\n ) {\n delta.translate = 0.0\n }\n}\n\nexport function calcBoxDelta(\n delta: Delta,\n source: Box,\n target: Box,\n origin?: ResolvedValues\n): void {\n calcAxisDelta(\n delta.x,\n source.x,\n target.x,\n origin ? (origin.originX as number) : undefined\n )\n calcAxisDelta(\n delta.y,\n source.y,\n target.y,\n origin ? (origin.originY as number) : undefined\n )\n}\n\nexport function calcRelativeAxis(target: Axis, relative: Axis, parent: Axis) {\n target.min = parent.min + relative.min\n target.max = target.min + calcLength(relative)\n}\n\nexport function calcRelativeBox(target: Box, relative: Box, parent: Box) {\n calcRelativeAxis(target.x, relative.x, parent.x)\n calcRelativeAxis(target.y, relative.y, parent.y)\n}\n\nexport function calcRelativeAxisPosition(\n target: Axis,\n layout: Axis,\n parent: Axis\n) {\n target.min = layout.min - parent.min\n target.max = target.min + calcLength(layout)\n}\n\nexport function calcRelativePosition(target: Box, layout: Box, parent: Box) {\n calcRelativeAxisPosition(target.x, layout.x, parent.x)\n calcRelativeAxisPosition(target.y, layout.y, parent.y)\n}\n"],"names":[],"mappings":";;AAIA,MAAM,eAAe,GAAG,MAAM;AAC9B,MAAM,SAAS,GAAG,CAAC,GAAG,eAAe;AACrC,MAAM,SAAS,GAAG,CAAC,GAAG,eAAe;AACrC,MAAM,mBAAmB,GAAG,IAAI;AAChC,MAAM,aAAa,GAAG,CAAC,GAAG,mBAAmB;AAC7C,MAAM,aAAa,GAAG,CAAC,GAAG,mBAAmB;AAEvC,SAAU,UAAU,CAAC,IAAU,EAAA;AACjC,IAAA,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG;AAC9B;SAEgB,MAAM,CAClB,KAAa,EACb,MAAc,EACd,WAAmB,EAAA;IAEnB,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,WAAW;AAClD;AAEM,SAAU,aAAa,CACzB,KAAgB,EAChB,MAAY,EACZ,MAAY,EACZ,MAAA,GAAiB,GAAG,EAAA;AAEpB,IAAA,KAAK,CAAC,MAAM,GAAG,MAAM;AACrB,IAAA,KAAK,CAAC,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC;AACnE,IAAA,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC;AACrD,IAAA,KAAK,CAAC,SAAS;AACX,QAAA,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,WAAW;AAEvE,IAAA,IACI,CAAC,KAAK,CAAC,KAAK,IAA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EZ,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG;IACpC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC;AAChD;SAEgB,oBAAoB,CAAC,MAAW,EAAE,MAAW,EAAE,MAAW,EAAA;AACtE,IAAA,wBAAwB,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AACtD,IAAA,wBAAwB,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1D;;;;"}
1
+ {"version":3,"file":"delta-calc.mjs","sources":["../../../../src/projection/geometry/delta-calc.ts"],"sourcesContent":["import { Axis, AxisDelta, Box, Delta, Point } from \"motion-utils\"\nimport { mixNumber } from \"../../utils/mix/number\"\nimport { ResolvedValues } from \"../../render/types\"\n\nconst SCALE_PRECISION = 0.0001\nconst SCALE_MIN = 1 - SCALE_PRECISION\nconst SCALE_MAX = 1 + SCALE_PRECISION\nconst TRANSLATE_PRECISION = 0.01\nconst TRANSLATE_MIN = 0 - TRANSLATE_PRECISION\nconst TRANSLATE_MAX = 0 + TRANSLATE_PRECISION\n\nexport function calcLength(axis: Axis) {\n return axis.max - axis.min\n}\n\nexport function isNear(\n value: number,\n target: number,\n maxDistance: number\n): boolean {\n return Math.abs(value - target) <= maxDistance\n}\n\nexport function calcAxisDelta(\n delta: AxisDelta,\n source: Axis,\n target: Axis,\n origin: number = 0.5\n) {\n delta.origin = origin\n delta.originPoint = mixNumber(source.min, source.max, delta.origin)\n delta.scale = calcLength(target) / calcLength(source)\n delta.translate =\n mixNumber(target.min, target.max, delta.origin) - delta.originPoint\n\n if (\n (delta.scale >= SCALE_MIN && delta.scale <= SCALE_MAX) ||\n isNaN(delta.scale)\n ) {\n delta.scale = 1.0\n }\n\n if (\n (delta.translate >= TRANSLATE_MIN &&\n delta.translate <= TRANSLATE_MAX) ||\n isNaN(delta.translate)\n ) {\n delta.translate = 0.0\n }\n}\n\nexport function calcBoxDelta(\n delta: Delta,\n source: Box,\n target: Box,\n origin?: ResolvedValues\n): void {\n calcAxisDelta(\n delta.x,\n source.x,\n target.x,\n origin ? (origin.originX as number) : undefined\n )\n calcAxisDelta(\n delta.y,\n source.y,\n target.y,\n origin ? (origin.originY as number) : undefined\n )\n}\n\nexport function calcRelativeAxis(\n target: Axis,\n relative: Axis,\n parent: Axis,\n anchor: number = 0\n) {\n const anchorPoint = anchor\n ? mixNumber(parent.min, parent.max, anchor)\n : parent.min\n target.min = anchorPoint + relative.min\n target.max = target.min + calcLength(relative)\n}\n\nexport function calcRelativeBox(\n target: Box,\n relative: Box,\n parent: Box,\n anchor?: Point\n) {\n calcRelativeAxis(target.x, relative.x, parent.x, anchor?.x)\n calcRelativeAxis(target.y, relative.y, parent.y, anchor?.y)\n}\n\nexport function calcRelativeAxisPosition(\n target: Axis,\n layout: Axis,\n parent: Axis,\n anchor: number = 0\n) {\n const anchorPoint = anchor\n ? mixNumber(parent.min, parent.max, anchor)\n : parent.min\n target.min = layout.min - anchorPoint\n target.max = target.min + calcLength(layout)\n}\n\nexport function calcRelativePosition(\n target: Box,\n layout: Box,\n parent: Box,\n anchor?: Point\n) {\n calcRelativeAxisPosition(target.x, layout.x, parent.x, anchor?.x)\n calcRelativeAxisPosition(target.y, layout.y, parent.y, anchor?.y)\n}\n"],"names":[],"mappings":";;AAIA,MAAM,eAAe,GAAG,MAAM;AAC9B,MAAM,SAAS,GAAG,CAAC,GAAG,eAAe;AACrC,MAAM,SAAS,GAAG,CAAC,GAAG,eAAe;AACrC,MAAM,mBAAmB,GAAG,IAAI;AAChC,MAAM,aAAa,GAAG,CAAC,GAAG,mBAAmB;AAC7C,MAAM,aAAa,GAAG,CAAC,GAAG,mBAAmB;AAEvC,SAAU,UAAU,CAAC,IAAU,EAAA;AACjC,IAAA,OAAO,IAAI,CAAC,GAAG,G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,oBAAoB,CAChC,MAAW,EACX,MAAW,EACX,MAAW,EACX,MAAc,EAAA;AAEd,IAAA,wBAAwB,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AACjE,IAAA,wBAAwB,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AACrE;;;;"}
@@ -452,8 +452,18 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
452
452
  // but should still clean up the measurements so that the next
453
453
  // snapshot could be taken correctly.
454
454
  if (updateWasBlocked) {
455
+ const wasBlockedByResize = this.updateBlockedByResize;
455
456
  this.unblockUpdate();
457
+ this.updateBlockedByResize = false;
456
458
  this.clearAllSnapshots();
459
+ /**
460
+ * When blocked by resize, still measure layouts so
461
+ * callbacks like onLayoutMeasure fire (e.g. Reorder).
462
+ * Skip notifyLayoutUpdate to prevent animations.
463
+ */
464
+ if (wasBlockedByResize) {
465
+ this.nodes.forEach(forceLayoutMeasure);
466
+ }
457
467
  this.nodes.forEach(clearMeasurements);
458
468
  return;
459
469
  }
@@ -470,6 +480,11 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
470
480
  }
471
481
  else {
472
482
  this.isUpdating = false;
483
+ /**
484
+ * Ensure animation-blocked nodes (e.g. during drag)
485
+ * get measured even when memoized (willUpdate skipped).
486
+ */
487
+ this.nodes.forEach(ensureDraggedNodesSnapshotted);
473
488
  /**
474
489
  * Write
475
490
  */
@@ -568,7 +583,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
568
583
  const prevLayout = this.layout;
569
584
  this.layout = this.measure(false);
570
585
  this.layoutVersion++;
571
- this.layoutCorrected = createBox();
586
+ if (!this.layoutCorrected)
587
+ this.layoutCorrected = createBox();
572
588
  this.isLayoutDirty = false;
573
589
  this.projectionDelta = undefined;
574
590
  this.notifyListeners("measure", this.layout.layoutBox);
@@ -679,8 +695,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
679
695
  }
680
696
  return boxWithoutScroll;
681
697
  }
682
- applyTransform(box, transformOnly = false) {
683
- const withTransforms = createBox();
698
+ applyTransform(box, transformOnly = false, output) {
699
+ const withTransforms = output || createBox();
684
700
  copyBoxInto(withTransforms, box);
685
701
  for (let i = 0; i < this.path.length; i++) {
686
702
  const node = this.path[i];
@@ -688,10 +704,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
688
704
  node.options.layoutScroll &&
689
705
  node.scroll &&
690
706
  node !== node.root) {
691
- transformBox(withTransforms, {
692
- x: -node.scroll.offset.x,
693
- y: -node.scroll.offset.y,
694
- });
707
+ translateAxis(withTransforms.x, -node.scroll.offset.x);
708
+ translateAxis(withTransforms.y, -node.scroll.offset.y);
695
709
  }
696
710
  if (!hasTransform(node.latestValues))
697
711
  continue;
@@ -799,7 +813,9 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
799
813
  * even if no animation has started.
800
814
  */
801
815
  if (!this.targetDelta && !this.relativeTarget) {
802
- if (relativeParent && relativeParent.layout) {
816
+ if (this.options.layoutAnchor !== false &&
817
+ relativeParent &&
818
+ relativeParent.layout) {
803
819
  this.createRelativeTarget(relativeParent, this.layout.layoutBox, relativeParent.layout.layoutBox);
804
820
  }
805
821
  else {
@@ -827,15 +843,14 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
827
843
  this.relativeParent &&
828
844
  this.relativeParent.target) {
829
845
  this.forceRelativeParentToResolveTarget();
830
- calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target);
846
+ calcRelativeBox(this.target, this.relativeTarget, this.relativeParent.target, this.options.layoutAnchor || undefined);
831
847
  /**
832
848
  * If we've only got a targetDelta, resolve it into a target
833
849
  */
834
850
  }
835
851
  else if (this.targetDelta) {
836
852
  if (Boolean(this.resumingFrom)) {
837
- // TODO: This is creating a new object every frame
838
- this.target = this.applyTransform(this.layout.layoutBox);
853
+ this.applyTransform(this.layout.layoutBox, false, this.target);
839
854
  }
840
855
  else {
841
856
  copyBoxInto(this.target, this.layout.layoutBox);
@@ -853,7 +868,8 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
853
868
  */
854
869
  if (this.attemptToResolveRelativeTarget) {
855
870
  this.attemptToResolveRelativeTarget = false;
856
- if (relativeParent &&
871
+ if (this.options.layoutAnchor !== false &&
872
+ relativeParent &&
857
873
  Boolean(relativeParent.resumingFrom) ===
858
874
  Boolean(this.resumingFrom) &&
859
875
  !relativeParent.options.layoutScroll &&
@@ -897,7 +913,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
897
913
  this.forceRelativeParentToResolveTarget();
898
914
  this.relativeTarget = createBox();
899
915
  this.relativeTargetOrigin = createBox();
900
- calcRelativePosition(this.relativeTargetOrigin, layout, parentLayout);
916
+ calcRelativePosition(this.relativeTargetOrigin, layout, parentLayout, this.options.layoutAnchor || undefined);
901
917
  copyBoxInto(this.relativeTarget, this.relativeTargetOrigin);
902
918
  }
903
919
  removeRelativeTarget() {
@@ -1069,7 +1085,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
1069
1085
  this.layout &&
1070
1086
  this.relativeParent &&
1071
1087
  this.relativeParent.layout) {
1072
- calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox);
1088
+ calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox, this.options.layoutAnchor || undefined);
1073
1089
  mixBox(this.relativeTarget, this.relativeTargetOrigin, relativeLayout, progress);
1074
1090
  /**
1075
1091
  * If this is an unchanged relative target we can consider the
@@ -1488,10 +1504,11 @@ function notifyLayoutUpdate(node) {
1488
1504
  if (relativeParent && !relativeParent.resumeFrom) {
1489
1505
  const { snapshot: parentSnapshot, layout: parentLayout } = relativeParent;
1490
1506
  if (parentSnapshot && parentLayout) {
1507
+ const anchor = node.options.layoutAnchor || undefined;
1491
1508
  const relativeSnapshot = createBox();
1492
- calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox);
1509
+ calcRelativePosition(relativeSnapshot, snapshot.layoutBox, parentSnapshot.layoutBox, anchor);
1493
1510
  const relativeLayout = createBox();
1494
- calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
1511
+ calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox, anchor);
1495
1512
  if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) {
1496
1513
  hasRelativeLayoutChanged = true;
1497
1514
  }
@@ -1563,9 +1580,25 @@ function clearSnapshot(node) {
1563
1580
  function clearMeasurements(node) {
1564
1581
  node.clearMeasurements();
1565
1582
  }
1583
+ function forceLayoutMeasure(node) {
1584
+ node.isLayoutDirty = true;
1585
+ node.updateLayout();
1586
+ }
1566
1587
  function clearIsLayoutDirty(node) {
1567
1588
  node.isLayoutDirty = false;
1568
1589
  }
1590
+ /**
1591
+ * When a node is animation-blocked (e.g. during drag) and its component
1592
+ * didn't re-render (memoized), willUpdate() is never called so there's
1593
+ * no snapshot. Use the previous layout as a snapshot and mark dirty so
1594
+ * resetTransform/updateLayout/notifyLayoutUpdate process it normally.
1595
+ */
1596
+ function ensureDraggedNodesSnapshotted(node) {
1597
+ if (node.isAnimationBlocked && node.layout && !node.isLayoutDirty) {
1598
+ node.snapshot = node.layout;
1599
+ node.isLayoutDirty = true;
1600
+ }
1601
+ }
1569
1602
  function resetTransformStyle(node) {
1570
1603
  const { visualElement } = node.options;
1571
1604
  if (visualElement && visualElement.getProps().onBeforeLayoutMeasure) {