motion-dom 12.28.2 → 12.29.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.
@@ -53,17 +53,30 @@ class NodeStack {
53
53
  if (prevLead) {
54
54
  prevLead.instance && prevLead.scheduleRender();
55
55
  node.scheduleRender();
56
- node.resumeFrom = prevLead;
57
- if (preserveFollowOpacity) {
58
- node.resumeFrom.preserveOpacity = true;
59
- }
60
- if (prevLead.snapshot) {
61
- node.snapshot = prevLead.snapshot;
62
- node.snapshot.latestValues =
63
- prevLead.animationValues || prevLead.latestValues;
64
- }
65
- if (node.root && node.root.isUpdating) {
66
- node.isLayoutDirty = true;
56
+ /**
57
+ * If both the new and previous lead have the same defined layoutDependency,
58
+ * skip the shared layout animation. This allows components with layoutId
59
+ * to opt-out of animations when their layoutDependency hasn't changed,
60
+ * even when the component unmounts and remounts in a different location.
61
+ */
62
+ const prevDep = prevLead.options.layoutDependency;
63
+ const nextDep = node.options.layoutDependency;
64
+ const dependencyMatches = prevDep !== undefined &&
65
+ nextDep !== undefined &&
66
+ prevDep === nextDep;
67
+ if (!dependencyMatches) {
68
+ node.resumeFrom = prevLead;
69
+ if (preserveFollowOpacity) {
70
+ node.resumeFrom.preserveOpacity = true;
71
+ }
72
+ if (prevLead.snapshot) {
73
+ node.snapshot = prevLead.snapshot;
74
+ node.snapshot.latestValues =
75
+ prevLead.animationValues || prevLead.latestValues;
76
+ }
77
+ if (node.root && node.root.isUpdating) {
78
+ node.isLayoutDirty = true;
79
+ }
67
80
  }
68
81
  const { crossfade } = node.options;
69
82
  if (crossfade === false) {
@@ -1 +1 @@
1
- {"version":3,"file":"stack.mjs","sources":["../../../../src/projection/shared/stack.ts"],"sourcesContent":["import { addUniqueItem, removeItem } from \"motion-utils\"\nimport { IProjectionNode } from \"../node/types\"\n\nexport class NodeStack {\n lead?: IProjectionNode\n prevLead?: IProjectionNode\n members: IProjectionNode[] = []\n\n add(node: IProjectionNode) {\n addUniqueItem(this.members, node)\n node.scheduleRender()\n }\n\n remove(node: IProjectionNode) {\n removeItem(this.members, node)\n if (node === this.prevLead) {\n this.prevLead = undefined\n }\n if (node === this.lead) {\n const prevLead = this.members[this.members.length - 1]\n if (prevLead) {\n this.promote(prevLead)\n }\n }\n }\n\n relegate(node: IProjectionNode): boolean {\n const indexOfNode = this.members.findIndex((member) => node === member)\n if (indexOfNode === 0) return false\n\n /**\n * Find the next projection node that is present\n */\n let prevLead: IProjectionNode | undefined\n for (let i = indexOfNode; i >= 0; i--) {\n const member = this.members[i]\n if (member.isPresent !== false) {\n prevLead = member\n break\n }\n }\n\n if (prevLead) {\n this.promote(prevLead)\n return true\n } else {\n return false\n }\n }\n\n promote(node: IProjectionNode, preserveFollowOpacity?: boolean) {\n const prevLead = this.lead\n\n if (node === prevLead) return\n\n this.prevLead = prevLead\n this.lead = node\n\n node.show()\n\n if (prevLead) {\n prevLead.instance && prevLead.scheduleRender()\n node.scheduleRender()\n node.resumeFrom = prevLead\n\n if (preserveFollowOpacity) {\n node.resumeFrom.preserveOpacity = true\n }\n\n if (prevLead.snapshot) {\n node.snapshot = prevLead.snapshot\n node.snapshot.latestValues =\n prevLead.animationValues || prevLead.latestValues\n }\n\n if (node.root && node.root.isUpdating) {\n node.isLayoutDirty = true\n }\n\n const { crossfade } = node.options\n if (crossfade === false) {\n prevLead.hide()\n }\n }\n }\n\n exitAnimationComplete() {\n this.members.forEach((node) => {\n const { options, resumingFrom } = node\n\n options.onExitComplete && options.onExitComplete()\n\n if (resumingFrom) {\n resumingFrom.options.onExitComplete &&\n resumingFrom.options.onExitComplete()\n }\n })\n }\n\n scheduleRender() {\n this.members.forEach((node) => {\n node.instance && node.scheduleRender(false)\n })\n }\n\n /**\n * Clear any leads that have been removed this render to prevent them from being\n * used in future animations and to prevent memory leaks\n */\n removeLeadSnapshot() {\n if (this.lead && this.lead.snapshot) {\n this.lead.snapshot = undefined\n }\n }\n}\n"],"names":[],"mappings":";;MAGa,SAAS,CAA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qB,GAAA;QACjB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AAC1B,YAAA,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;AAEtC,YAAA,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,cAAc,EAAE,CAAA;YAElD,IAAI,YAAY,EAAE;gBACd,YAAY,CAAC,OAAO,CAAC,cAAc;AAC/B,oBAAA,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;aAC5C;AACL,SAAC,CAAC,CAAA;KACL;IAED,cAAc,GAAA;QACV,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;YAC1B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;AAC/C,SAAC,CAAC,CAAA;KACL;AAED;;;AAGG;IACH,kBAAkB,GAAA;QACd,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;AACjC,YAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;SACjC;KACJ;AACJ;;;;"}
1
+ {"version":3,"file":"stack.mjs","sources":["../../../../src/projection/shared/stack.ts"],"sourcesContent":["import { addUniqueItem, removeItem } from \"motion-utils\"\nimport { IProjectionNode } from \"../node/types\"\n\nexport class NodeStack {\n lead?: IProjectionNode\n prevLead?: IProjectionNode\n members: IProjectionNode[] = []\n\n add(node: IProjectionNode) {\n addUniqueItem(this.members, node)\n node.scheduleRender()\n }\n\n remove(node: IProjectionNode) {\n removeItem(this.members, node)\n if (node === this.prevLead) {\n this.prevLead = undefined\n }\n if (node === this.lead) {\n const prevLead = this.members[this.members.length - 1]\n if (prevLead) {\n this.promote(prevLead)\n }\n }\n }\n\n relegate(node: IProjectionNode): boolean {\n const indexOfNode = this.members.findIndex((member) => node === member)\n if (indexOfNode === 0) return false\n\n /**\n * Find the next projection node that is present\n */\n let prevLead: IProjectionNode | undefined\n for (let i = indexOfNode; i >= 0; i--) {\n const member = this.members[i]\n if (member.isPresent !== false) {\n prevLead = member\n break\n }\n }\n\n if (prevLead) {\n this.promote(prevLead)\n return true\n } else {\n return false\n }\n }\n\n promote(node: IProjectionNode, preserveFollowOpacity?: boolean) {\n const prevLead = this.lead\n\n if (node === prevLead) return\n\n this.prevLead = prevLead\n this.lead = node\n\n node.show()\n\n if (prevLead) {\n prevLead.instance && prevLead.scheduleRender()\n node.scheduleRender()\n\n /**\n * If both the new and previous lead have the same defined layoutDependency,\n * skip the shared layout animation. This allows components with layoutId\n * to opt-out of animations when their layoutDependency hasn't changed,\n * even when the component unmounts and remounts in a different location.\n */\n const prevDep = prevLead.options.layoutDependency\n const nextDep = node.options.layoutDependency\n const dependencyMatches =\n prevDep !== undefined &&\n nextDep !== undefined &&\n prevDep === nextDep\n\n if (!dependencyMatches) {\n node.resumeFrom = prevLead\n\n if (preserveFollowOpacity) {\n node.resumeFrom.preserveOpacity = true\n }\n\n if (prevLead.snapshot) {\n node.snapshot = prevLead.snapshot\n node.snapshot.latestValues =\n prevLead.animationValues || prevLead.latestValues\n }\n\n if (node.root && node.root.isUpdating) {\n node.isLayoutDirty = true\n }\n }\n\n const { crossfade } = node.options\n if (crossfade === false) {\n prevLead.hide()\n }\n }\n }\n\n exitAnimationComplete() {\n this.members.forEach((node) => {\n const { options, resumingFrom } = node\n\n options.onExitComplete && options.onExitComplete()\n\n if (resumingFrom) {\n resumingFrom.options.onExitComplete &&\n resumingFrom.options.onExitComplete()\n }\n })\n }\n\n scheduleRender() {\n this.members.forEach((node) => {\n node.instance && node.scheduleRender(false)\n })\n }\n\n /**\n * Clear any leads that have been removed this render to prevent them from being\n * used in future animations and to prevent memory leaks\n */\n removeLeadSnapshot() {\n if (this.lead && this.lead.snapshot) {\n this.lead.snapshot = undefined\n }\n }\n}\n"],"names":[],"mappings":";;MAGa,SAAS,CAAA;AAAtB,IAAA,WAAA,GAAA;QAGI,IAAO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AAI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;AACnC,oBAAA,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;iBAC5B;aACJ;AAED,YAAA,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,OAAO,CAAA;AAClC,YAAA,IAAI,SAAS,KAAK,KAAK,EAAE;gBACrB,QAAQ,CAAC,IAAI,EAAE,CAAA;aAClB;SACJ;KACJ;IAED,qBAAqB,GAAA;QACjB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AAC1B,YAAA,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;AAEtC,YAAA,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,cAAc,EAAE,CAAA;YAElD,IAAI,YAAY,EAAE;gBACd,YAAY,CAAC,OAAO,CAAC,cAAc;AAC/B,oBAAA,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;aAC5C;AACL,SAAC,CAAC,CAAA;KACL;IAED,cAAc,GAAA;QACV,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;YAC1B,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;AAC/C,SAAC,CAAC,CAAA;KACL;AAED;;;AAGG;IACH,kBAAkB,GAAA;QACd,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;AACjC,YAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAA;SACjC;KACJ;AACJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"SVGVisualElement.mjs","sources":["../../../../src/render/svg/SVGVisualElement.ts"],"sourcesContent":["import type { AnyResolvedKeyframe } from \"../../animation/types\"\nimport type { MotionValue } from \"../../value\"\nimport type { MotionNodeOptions } from \"../../node/types\"\nimport { transformProps } from \"../utils/keys-transform\"\nimport { getDefaultValueType } from \"../../value/types/maps/defaults\"\nimport { createBox } from \"../../projection/geometry/models\"\nimport { DOMVisualElement } from \"../dom/DOMVisualElement\"\nimport type { DOMVisualElementOptions } from \"../dom/types\"\nimport { camelToDash } from \"../dom/utils/camel-to-dash\"\nimport type { ResolvedValues } from \"../types\"\nimport type { VisualElement, MotionStyle } from \"../VisualElement\"\nimport { SVGRenderState } from \"./types\"\nimport { buildSVGAttrs } from \"./utils/build-attrs\"\nimport { camelCaseAttributes } from \"./utils/camel-case-attrs\"\nimport { isSVGTag } from \"./utils/is-svg-tag\"\nimport { renderSVG } from \"./utils/render\"\nimport { scrapeMotionValuesFromProps } from \"./utils/scrape-motion-values\"\n\nexport class SVGVisualElement extends DOMVisualElement<\n SVGElement,\n SVGRenderState,\n DOMVisualElementOptions\n> {\n type = \"svg\"\n\n isSVGTag = false\n\n getBaseTargetFromProps(\n props: MotionNodeOptions,\n key: string\n ): AnyResolvedKeyframe | MotionValue<any> | undefined {\n return props[key as keyof MotionNodeOptions]\n }\n\n readValueFromInstance(instance: SVGElement, key: string) {\n if (transformProps.has(key)) {\n const defaultType = getDefaultValueType(key)\n return defaultType ? defaultType.default || 0 : 0\n }\n key = !camelCaseAttributes.has(key) ? camelToDash(key) : key\n return instance.getAttribute(key)\n }\n\n measureInstanceViewportBox = createBox\n\n scrapeMotionValuesFromProps(\n props: MotionNodeOptions,\n prevProps: MotionNodeOptions,\n visualElement: VisualElement\n ) {\n return scrapeMotionValuesFromProps(props, prevProps, visualElement)\n }\n\n build(\n renderState: SVGRenderState,\n latestValues: ResolvedValues,\n props: MotionNodeOptions\n ) {\n buildSVGAttrs(\n renderState,\n latestValues,\n this.isSVGTag,\n props.transformTemplate,\n (props as any).style\n )\n }\n\n renderInstance(\n instance: SVGElement,\n renderState: SVGRenderState,\n styleProp?: MotionStyle | undefined,\n projection?: any\n ): void {\n renderSVG(instance, renderState, styleProp, projection)\n }\n\n mount(instance: SVGElement) {\n this.isSVGTag = isSVGTag(instance.tagName)\n super.m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,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,CAAC,CAAA;KAC1D;AAED,IAAA,KAAK,CAAC,QAAoB,EAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAC1C,QAAA,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;KACxB;AACJ;;;;"}
1
+ {"version":3,"file":"SVGVisualElement.mjs","sources":["../../../../src/render/svg/SVGVisualElement.ts"],"sourcesContent":["import type { AnyResolvedKeyframe } from \"../../animation/types\"\nimport type { MotionValue } from \"../../value\"\nimport type { MotionNodeOptions } from \"../../node/types\"\nimport { transformProps } from \"../utils/keys-transform\"\nimport { getDefaultValueType } from \"../../value/types/maps/defaults\"\nimport { createBox } from \"../../projection/geometry/models\"\nimport { DOMVisualElement } from \"../dom/DOMVisualElement\"\nimport type { DOMVisualElementOptions } from \"../dom/types\"\nimport { camelToDash } from \"../dom/utils/camel-to-dash\"\nimport type { ResolvedValues } from \"../types\"\nimport type { VisualElement, MotionStyle } from \"../VisualElement\"\nimport { SVGRenderState } from \"./types\"\nimport { buildSVGAttrs } from \"./utils/build-attrs\"\nimport { camelCaseAttributes } from \"./utils/camel-case-attrs\"\nimport { isSVGTag } from \"./utils/is-svg-tag\"\nimport { renderSVG } from \"./utils/render\"\nimport { scrapeMotionValuesFromProps } from \"./utils/scrape-motion-values\"\nexport class SVGVisualElement extends DOMVisualElement<\n SVGElement,\n SVGRenderState,\n DOMVisualElementOptions\n> {\n type = \"svg\"\n\n isSVGTag = false\n\n getBaseTargetFromProps(\n props: MotionNodeOptions,\n key: string\n ): AnyResolvedKeyframe | MotionValue<any> | undefined {\n return props[key as keyof MotionNodeOptions]\n }\n\n readValueFromInstance(instance: SVGElement, key: string) {\n if (transformProps.has(key)) {\n const defaultType = getDefaultValueType(key)\n return defaultType ? defaultType.default || 0 : 0\n }\n key = !camelCaseAttributes.has(key) ? camelToDash(key) : key\n return instance.getAttribute(key)\n }\n\n measureInstanceViewportBox = createBox\n\n scrapeMotionValuesFromProps(\n props: MotionNodeOptions,\n prevProps: MotionNodeOptions,\n visualElement: VisualElement\n ) {\n return scrapeMotionValuesFromProps(props, prevProps, visualElement)\n }\n\n build(\n renderState: SVGRenderState,\n latestValues: ResolvedValues,\n props: MotionNodeOptions\n ) {\n buildSVGAttrs(\n renderState,\n latestValues,\n this.isSVGTag,\n props.transformTemplate,\n (props as any).style\n )\n }\n\n renderInstance(\n instance: SVGElement,\n renderState: SVGRenderState,\n styleProp?: MotionStyle | undefined,\n projection?: any\n ): void {\n renderSVG(instance, renderState, styleProp, projection)\n }\n\n mount(instance: SVGElement) {\n this.isSVGTag = isSVGTag(instance.tagName)\n super.mount(instance)\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiBM,MAAO,gBAAiB,SAAQ,gBAIrC,CAAA;AAJD,IAAA,WAAA,GAAA;;QAKI,IAAI,CAAA,IAAA,GAAG,KAAK,CAAA;QAEZ,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAA;QAkBhB,IAA0B,CAAA,0BAAA,GAAG,SAAS,CAAA;KAqCzC;IArDG,sBAAsB,CAClB,KAAwB,EACxB,GAAW,EAAA;AAEX,QAAA,OAAO,KAAK,CAAC,GAA8B,CAAC,CAAA;KAC/C;IAED,qBAAqB,CAAC,QAAoB,EAAE,GAAW,EAAA;AACnD,QAAA,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACzB,YAAA,MAAM,WAAW,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAA;AAC5C,YAAA,OAAO,WAAW,GAAG,WAAW,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;SACpD;AACD,QAAA,GAAG,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;AAC5D,QAAA,OAAO,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;KACpC;AAID,IAAA,2BAA2B,CACvB,KAAwB,EACxB,SAA4B,EAC5B,aAA4B,EAAA;QAE5B,OAAO,2BAA2B,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,CAAA;KACtE;AAED,IAAA,KAAK,CACD,WAA2B,EAC3B,YAA4B,EAC5B,KAAwB,EAAA;AAExB,QAAA,aAAa,CACT,WAAW,EACX,YAAY,EACZ,IAAI,CAAC,QAAQ,EACb,KAAK,CAAC,iBAAiB,EACtB,KAAa,CAAC,KAAK,CACvB,CAAA;KACJ;AAED,IAAA,cAAc,CACV,QAAoB,EACpB,WAA2B,EAC3B,SAAmC,EACnC,UAAgB,EAAA;QAEhB,SAAS,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,CAAC,CAAA;KAC1D;AAED,IAAA,KAAK,CAAC,QAAoB,EAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAC1C,QAAA,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;KACxB;AACJ;;;;"}
package/dist/index.d.ts CHANGED
@@ -4251,6 +4251,7 @@ interface ProjectionNodeOptions {
4251
4251
  crossfade?: boolean;
4252
4252
  transition?: Transition;
4253
4253
  initialPromotionConfig?: InitialPromotionConfig;
4254
+ layoutDependency?: unknown;
4254
4255
  }
4255
4256
  type ProjectionEventName = "layoutUpdate" | "projectionUpdate";
4256
4257
 
@@ -7339,17 +7339,30 @@
7339
7339
  if (prevLead) {
7340
7340
  prevLead.instance && prevLead.scheduleRender();
7341
7341
  node.scheduleRender();
7342
- node.resumeFrom = prevLead;
7343
- if (preserveFollowOpacity) {
7344
- node.resumeFrom.preserveOpacity = true;
7345
- }
7346
- if (prevLead.snapshot) {
7347
- node.snapshot = prevLead.snapshot;
7348
- node.snapshot.latestValues =
7349
- prevLead.animationValues || prevLead.latestValues;
7350
- }
7351
- if (node.root && node.root.isUpdating) {
7352
- node.isLayoutDirty = true;
7342
+ /**
7343
+ * If both the new and previous lead have the same defined layoutDependency,
7344
+ * skip the shared layout animation. This allows components with layoutId
7345
+ * to opt-out of animations when their layoutDependency hasn't changed,
7346
+ * even when the component unmounts and remounts in a different location.
7347
+ */
7348
+ const prevDep = prevLead.options.layoutDependency;
7349
+ const nextDep = node.options.layoutDependency;
7350
+ const dependencyMatches = prevDep !== undefined &&
7351
+ nextDep !== undefined &&
7352
+ prevDep === nextDep;
7353
+ if (!dependencyMatches) {
7354
+ node.resumeFrom = prevLead;
7355
+ if (preserveFollowOpacity) {
7356
+ node.resumeFrom.preserveOpacity = true;
7357
+ }
7358
+ if (prevLead.snapshot) {
7359
+ node.snapshot = prevLead.snapshot;
7360
+ node.snapshot.latestValues =
7361
+ prevLead.animationValues || prevLead.latestValues;
7362
+ }
7363
+ if (node.root && node.root.isUpdating) {
7364
+ node.isLayoutDirty = true;
7365
+ }
7353
7366
  }
7354
7367
  const { crossfade } = node.options;
7355
7368
  if (crossfade === false) {