framer-motion 12.24.5 → 12.24.7
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/client.js +1 -1
- package/dist/cjs/dom.js +17 -9
- package/dist/cjs/dom.js.map +1 -1
- package/dist/cjs/{feature-bundle-BwaqZAbT.js → feature-bundle-C6mMBZjn.js} +18 -10
- package/dist/cjs/feature-bundle-C6mMBZjn.js.map +1 -0
- package/dist/cjs/index.js +10 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/dom.js +1 -1
- package/dist/es/components/AnimatePresence/index.mjs +9 -0
- package/dist/es/components/AnimatePresence/index.mjs.map +1 -1
- package/dist/es/render/VisualElement.mjs +16 -8
- package/dist/es/render/VisualElement.mjs.map +1 -1
- package/dist/framer-motion.dev.js +25 -8
- package/dist/framer-motion.js +1 -1
- package/dist/size-rollup-animate.js +1 -1
- package/dist/size-rollup-animate.js.map +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-rollup-motion.js.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/feature-bundle-BwaqZAbT.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisualElement.mjs","sources":["../../../src/render/VisualElement.ts"],"sourcesContent":["import {\n cancelFrame,\n complex,\n findValueType,\n frame,\n getAnimatableNone,\n isMotionValue,\n KeyframeResolver,\n microtask,\n motionValue,\n time,\n transformProps,\n type AnyResolvedKeyframe,\n type MotionValue,\n} from \"motion-dom\"\nimport type { Box } from \"motion-utils\"\nimport {\n isNumericalString,\n isZeroValueString,\n SubscriptionManager,\n warnOnce,\n} from \"motion-utils\"\nimport {\n MotionConfigContext,\n ReducedMotionConfig,\n} from \"../context/MotionConfigContext\"\nimport type { PresenceContextProps } from \"../context/PresenceContext\"\nimport { featureDefinitions } from \"../motion/features/definitions\"\nimport { Feature } from \"../motion/features/Feature\"\nimport { FeatureDefinitions } from \"../motion/features/types\"\nimport { MotionProps, MotionStyle } from \"../motion/types\"\nimport { createBox } from \"../projection/geometry/models\"\nimport { IProjectionNode } from \"../projection/node/types\"\nimport { initPrefersReducedMotion } from \"../utils/reduced-motion\"\nimport {\n hasReducedMotionListener,\n prefersReducedMotion,\n} from \"../utils/reduced-motion/state\"\nimport { visualElementStore } from \"./store\"\nimport {\n ResolvedValues,\n VisualElementEventCallbacks,\n VisualElementOptions,\n} from \"./types\"\nimport { AnimationState } from \"./utils/animation-state\"\nimport {\n isControllingVariants as checkIsControllingVariants,\n isVariantNode as checkIsVariantNode,\n} from \"./utils/is-controlling-variants\"\nimport { updateMotionValuesFromProps } from \"./utils/motion-values\"\nimport { resolveVariantFromProps } from \"./utils/resolve-variants\"\n\nconst propEventHandlers = [\n \"AnimationStart\",\n \"AnimationComplete\",\n \"Update\",\n \"BeforeLayoutMeasure\",\n \"LayoutMeasure\",\n \"LayoutAnimationStart\",\n \"LayoutAnimationComplete\",\n] as const\n\n/**\n * A VisualElement is an imperative abstraction around UI elements such as\n * HTMLElement, SVGElement, Three.Object3D etc.\n */\nexport abstract class VisualElement<\n Instance = unknown,\n RenderState = unknown,\n Options extends {} = {}\n> {\n /**\n * VisualElements are arranged in trees mirroring that of the React tree.\n * Each type of VisualElement has a unique name, to detect when we're crossing\n * type boundaries within that tree.\n */\n abstract type: string\n\n /**\n * An `Array.sort` compatible function that will compare two Instances and\n * compare their respective positions within the tree.\n */\n abstract sortInstanceNodePosition(a: Instance, b: Instance): number\n\n /**\n * Measure the viewport-relative bounding box of the Instance.\n */\n abstract measureInstanceViewportBox(\n instance: Instance,\n props: MotionProps & Partial<MotionConfigContext>\n ): Box\n\n /**\n * When a value has been removed from all animation props we need to\n * pick a target to animate back to. For instance, for HTMLElements\n * we can look in the style prop.\n */\n abstract getBaseTargetFromProps(\n props: MotionProps,\n key: string\n ): AnyResolvedKeyframe | undefined | MotionValue\n\n /**\n * When we first animate to a value we need to animate it *from* a value.\n * Often this have been specified via the initial prop but it might be\n * that the value needs to be read from the Instance.\n */\n abstract readValueFromInstance(\n instance: Instance,\n key: string,\n options: Options\n ): AnyResolvedKeyframe | null | undefined\n\n /**\n * When a value has been removed from the VisualElement we use this to remove\n * it from the inherting class' unique render state.\n */\n abstract removeValueFromRenderState(\n key: string,\n renderState: RenderState\n ): void\n\n /**\n * Run before a React or VisualElement render, builds the latest motion\n * values into an Instance-specific format. For example, HTMLVisualElement\n * will use this step to build `style` and `var` values.\n */\n abstract build(\n renderState: RenderState,\n latestValues: ResolvedValues,\n props: MotionProps\n ): void\n\n /**\n * Apply the built values to the Instance. For example, HTMLElements will have\n * styles applied via `setProperty` and the style attribute, whereas SVGElements\n * will have values applied to attributes.\n */\n abstract renderInstance(\n instance: Instance,\n renderState: RenderState,\n styleProp?: MotionStyle,\n projection?: IProjectionNode\n ): void\n\n /**\n * This method is called when a transform property is bound to a motion value.\n * It's currently used to measure SVG elements when a new transform property is bound.\n */\n onBindTransform?(): void\n\n /**\n * If the component child is provided as a motion value, handle subscriptions\n * with the renderer-specific VisualElement.\n */\n handleChildMotionValue?(): void\n\n /**\n * This method takes React props and returns found MotionValues. For example, HTML\n * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.\n *\n * This isn't an abstract method as it needs calling in the constructor, but it is\n * intended to be one.\n */\n scrapeMotionValuesFromProps(\n _props: MotionProps,\n _prevProps: MotionProps,\n _visualElement: VisualElement\n ): {\n [key: string]: MotionValue | AnyResolvedKeyframe\n } {\n return {}\n }\n\n /**\n * A reference to the current underlying Instance, e.g. a HTMLElement\n * or Three.Mesh etc.\n */\n current: Instance | null = null\n\n /**\n * A reference to the parent VisualElement (if exists).\n */\n parent: VisualElement | undefined\n\n /**\n * A set containing references to this VisualElement's children.\n */\n children = new Set<VisualElement>()\n\n /**\n * A set containing the latest children of this VisualElement. This is flushed\n * at the start of every commit. We use it to calculate the stagger delay\n * for newly-added children.\n */\n enteringChildren?: Set<VisualElement>\n\n /**\n * The depth of this VisualElement within the overall VisualElement tree.\n */\n depth: number\n\n /**\n * The current render state of this VisualElement. Defined by inherting VisualElements.\n */\n renderState: RenderState\n\n /**\n * An object containing the latest static values for each of this VisualElement's\n * MotionValues.\n */\n latestValues: ResolvedValues\n\n /**\n * Determine what role this visual element should take in the variant tree.\n */\n isVariantNode: boolean = false\n isControllingVariants: boolean = false\n\n /**\n * If this component is part of the variant tree, it should track\n * any children that are also part of the tree. This is essentially\n * a shadow tree to simplify logic around how to stagger over children.\n */\n variantChildren?: Set<VisualElement>\n\n /**\n * Decides whether this VisualElement should animate in reduced motion\n * mode.\n *\n * TODO: This is currently set on every individual VisualElement but feels\n * like it could be set globally.\n */\n shouldReduceMotion: boolean | null = null\n\n /**\n * Normally, if a component is controlled by a parent's variants, it can\n * rely on that ancestor to trigger animations further down the tree.\n * However, if a component is created after its parent is mounted, the parent\n * won't trigger that mount animation so the child needs to.\n *\n * TODO: This might be better replaced with a method isParentMounted\n */\n manuallyAnimateOnMount: boolean\n\n /**\n * This can be set by AnimatePresence to force components that mount\n * at the same time as it to mount as if they have initial={false} set.\n */\n blockInitialAnimation: boolean\n\n /**\n * A reference to this VisualElement's projection node, used in layout animations.\n */\n projection?: IProjectionNode\n\n /**\n * A map of all motion values attached to this visual element. Motion\n * values are source of truth for any given animated value. A motion\n * value might be provided externally by the component via props.\n */\n values = new Map<string, MotionValue>()\n\n /**\n * The AnimationState, this is hydrated by the animation Feature.\n */\n animationState?: AnimationState\n\n KeyframeResolver = KeyframeResolver\n\n /**\n * The options used to create this VisualElement. The Options type is defined\n * by the inheriting VisualElement and is passed straight through to the render functions.\n */\n readonly options: Options\n\n /**\n * A reference to the latest props provided to the VisualElement's host React component.\n */\n props: MotionProps\n prevProps?: MotionProps\n\n presenceContext: PresenceContextProps | null\n prevPresenceContext?: PresenceContextProps | null\n\n /**\n * Cleanup functions for active features (hover/tap/exit etc)\n */\n private features: {\n [K in keyof FeatureDefinitions]?: Feature<Instance>\n } = {}\n\n /**\n * A map of every subscription that binds the provided or generated\n * motion values onChange listeners to this visual element.\n */\n private valueSubscriptions = new Map<string, VoidFunction>()\n\n /**\n * A reference to the ReducedMotionConfig passed to the VisualElement's host React component.\n */\n private reducedMotionConfig: ReducedMotionConfig | undefined\n\n /**\n * On mount, this will be hydrated with a callback to disconnect\n * this visual element from its parent on unmount.\n */\n private removeFromVariantTree: undefined | VoidFunction\n\n /**\n * A reference to the previously-provided motion values as returned\n * from scrapeMotionValuesFromProps. We use the keys in here to determine\n * if any motion values need to be removed after props are updated.\n */\n private prevMotionValues: MotionStyle = {}\n\n /**\n * When values are removed from all animation props we need to search\n * for a fallback value to animate to. These values are tracked in baseTarget.\n */\n private baseTarget: ResolvedValues\n\n /**\n * Create an object of the values we initially animated from (if initial prop present).\n */\n private initialValues: ResolvedValues\n\n /**\n * An object containing a SubscriptionManager for each active event.\n */\n private events: {\n [key: string]: SubscriptionManager<any>\n } = {}\n\n /**\n * An object containing an unsubscribe function for each prop event subscription.\n * For example, every \"Update\" event can have multiple subscribers via\n * VisualElement.on(), but only one of those can be defined via the onUpdate prop.\n */\n private propEventSubscriptions: {\n [key: string]: VoidFunction\n } = {}\n\n constructor(\n {\n parent,\n props,\n presenceContext,\n reducedMotionConfig,\n blockInitialAnimation,\n visualState,\n }: VisualElementOptions<Instance, RenderState>,\n options: Options = {} as any\n ) {\n const { latestValues, renderState } = visualState\n this.latestValues = latestValues\n this.baseTarget = { ...latestValues }\n this.initialValues = props.initial ? { ...latestValues } : {}\n this.renderState = renderState\n this.parent = parent\n this.props = props\n this.presenceContext = presenceContext\n this.depth = parent ? parent.depth + 1 : 0\n this.reducedMotionConfig = reducedMotionConfig\n this.options = options\n this.blockInitialAnimation = Boolean(blockInitialAnimation)\n\n this.isControllingVariants = checkIsControllingVariants(props)\n this.isVariantNode = checkIsVariantNode(props)\n if (this.isVariantNode) {\n this.variantChildren = new Set()\n }\n\n this.manuallyAnimateOnMount = Boolean(parent && parent.current)\n\n /**\n * Any motion values that are provided to the element when created\n * aren't yet bound to the element, as this would technically be impure.\n * However, we iterate through the motion values and set them to the\n * initial values for this component.\n *\n * TODO: This is impure and we should look at changing this to run on mount.\n * Doing so will break some tests but this isn't necessarily a breaking change,\n * more a reflection of the test.\n */\n const { willChange, ...initialMotionValues } =\n this.scrapeMotionValuesFromProps(props, {}, this)\n\n for (const key in initialMotionValues) {\n const value = initialMotionValues[key]\n\n if (latestValues[key] !== undefined && isMotionValue(value)) {\n value.set(latestValues[key])\n }\n }\n }\n\n mount(instance: Instance) {\n this.current = instance\n\n visualElementStore.set(instance, this)\n\n if (this.projection && !this.projection.instance) {\n this.projection.mount(instance)\n }\n\n if (this.parent && this.isVariantNode && !this.isControllingVariants) {\n this.removeFromVariantTree = this.parent.addVariantChild(this)\n }\n\n this.values.forEach((value, key) => this.bindToMotionValue(key, value))\n\n if (!hasReducedMotionListener.current) {\n initPrefersReducedMotion()\n }\n\n this.shouldReduceMotion =\n this.reducedMotionConfig === \"never\"\n ? false\n : this.reducedMotionConfig === \"always\"\n ? true\n : prefersReducedMotion.current\n\n if (process.env.NODE_ENV !== \"production\") {\n warnOnce(\n this.shouldReduceMotion !== true,\n \"You have Reduced Motion enabled on your device. Animations may not appear as expected.\",\n \"reduced-motion-disabled\"\n )\n }\n\n this.parent?.addChild(this)\n\n this.update(this.props, this.presenceContext)\n }\n\n unmount() {\n this.projection && this.projection.unmount()\n cancelFrame(this.notifyUpdate)\n cancelFrame(this.render)\n this.valueSubscriptions.forEach((remove) => remove())\n this.valueSubscriptions.clear()\n this.removeFromVariantTree && this.removeFromVariantTree()\n this.parent?.removeChild(this)\n\n for (const key in this.events) {\n this.events[key].clear()\n }\n\n for (const key in this.features) {\n const feature = this.features[key as keyof typeof this.features]\n if (feature) {\n feature.unmount()\n feature.isMounted = false\n }\n }\n this.current = null\n }\n\n addChild(child: VisualElement) {\n this.children.add(child)\n this.enteringChildren ??= new Set()\n this.enteringChildren.add(child)\n }\n\n removeChild(child: VisualElement) {\n this.children.delete(child)\n this.enteringChildren && this.enteringChildren.delete(child)\n }\n\n private bindToMotionValue(key: string, value: MotionValue) {\n if (this.valueSubscriptions.has(key)) {\n this.valueSubscriptions.get(key)!()\n }\n\n const valueIsTransform = transformProps.has(key)\n\n if (valueIsTransform && this.onBindTransform) {\n this.onBindTransform()\n }\n\n const removeOnChange = value.on(\n \"change\",\n (latestValue: AnyResolvedKeyframe) => {\n this.latestValues[key] = latestValue\n\n this.props.onUpdate && frame.preRender(this.notifyUpdate)\n\n if (valueIsTransform && this.projection) {\n this.projection.isTransformDirty = true\n }\n\n this.scheduleRender()\n }\n )\n\n let removeSyncCheck: VoidFunction | void\n if (window.MotionCheckAppearSync) {\n removeSyncCheck = window.MotionCheckAppearSync(this, key, value)\n }\n\n this.valueSubscriptions.set(key, () => {\n removeOnChange()\n if (removeSyncCheck) removeSyncCheck()\n if (value.owner) value.stop()\n })\n }\n\n sortNodePosition(other: VisualElement<Instance>) {\n /**\n * If these nodes aren't even of the same type we can't compare their depth.\n */\n if (\n !this.current ||\n !this.sortInstanceNodePosition ||\n this.type !== other.type\n ) {\n return 0\n }\n\n return this.sortInstanceNodePosition(\n this.current as Instance,\n other.current as Instance\n )\n }\n\n updateFeatures() {\n let key: keyof typeof featureDefinitions = \"animation\"\n\n for (key in featureDefinitions) {\n const featureDefinition = featureDefinitions[key]\n\n if (!featureDefinition) continue\n\n const { isEnabled, Feature: FeatureConstructor } = featureDefinition\n\n /**\n * If this feature is enabled but not active, make a new instance.\n */\n if (\n !this.features[key] &&\n FeatureConstructor &&\n isEnabled(this.props)\n ) {\n this.features[key] = new FeatureConstructor(this) as any\n }\n\n /**\n * If we have a feature, mount or update it.\n */\n if (this.features[key]) {\n const feature = this.features[key]!\n if (feature.isMounted) {\n feature.update()\n } else {\n feature.mount()\n feature.isMounted = true\n }\n }\n }\n }\n\n notifyUpdate = () => this.notify(\"Update\", this.latestValues)\n\n triggerBuild() {\n this.build(this.renderState, this.latestValues, this.props)\n }\n\n render = () => {\n if (!this.current) return\n this.triggerBuild()\n this.renderInstance(\n this.current,\n this.renderState,\n this.props.style,\n this.projection\n )\n }\n\n private renderScheduledAt = 0.0\n scheduleRender = () => {\n const now = time.now()\n if (this.renderScheduledAt < now) {\n this.renderScheduledAt = now\n frame.render(this.render, false, true)\n }\n }\n\n /**\n * Measure the current viewport box with or without transforms.\n * Only measures axis-aligned boxes, rotate and skew must be manually\n * removed with a re-render to work.\n */\n measureViewportBox() {\n return this.current\n ? this.measureInstanceViewportBox(this.current, this.props)\n : createBox()\n }\n\n getStaticValue(key: string) {\n return this.latestValues[key]\n }\n\n setStaticValue(key: string, value: AnyResolvedKeyframe) {\n this.latestValues[key] = value\n }\n\n /**\n * Update the provided props. Ensure any newly-added motion values are\n * added to our map, old ones removed, and listeners updated.\n */\n update(props: MotionProps, presenceContext: PresenceContextProps | null) {\n if (props.transformTemplate || this.props.transformTemplate) {\n this.scheduleRender()\n }\n\n this.prevProps = this.props\n this.props = props\n\n this.prevPresenceContext = this.presenceContext\n this.presenceContext = presenceContext\n\n /**\n * Update prop event handlers ie onAnimationStart, onAnimationComplete\n */\n for (let i = 0; i < propEventHandlers.length; i++) {\n const key = propEventHandlers[i]\n if (this.propEventSubscriptions[key]) {\n this.propEventSubscriptions[key]()\n delete this.propEventSubscriptions[key]\n }\n\n const listenerName = (\"on\" + key) as keyof typeof props\n const listener = props[listenerName]\n if (listener) {\n this.propEventSubscriptions[key] = this.on(key as any, listener)\n }\n }\n\n this.prevMotionValues = updateMotionValuesFromProps(\n this,\n this.scrapeMotionValuesFromProps(props, this.prevProps, this),\n this.prevMotionValues\n )\n\n if (this.handleChildMotionValue) {\n this.handleChildMotionValue()\n }\n }\n\n getProps() {\n return this.props\n }\n\n /**\n * Returns the variant definition with a given name.\n */\n getVariant(name: string) {\n return this.props.variants ? this.props.variants[name] : undefined\n }\n\n /**\n * Returns the defined default transition on this component.\n */\n getDefaultTransition() {\n return this.props.transition\n }\n\n getTransformPagePoint() {\n return (this.props as any).transformPagePoint\n }\n\n getClosestVariantNode(): VisualElement | undefined {\n return this.isVariantNode\n ? this\n : this.parent\n ? this.parent.getClosestVariantNode()\n : undefined\n }\n\n /**\n * Add a child visual element to our set of children.\n */\n addVariantChild(child: VisualElement) {\n const closestVariantNode = this.getClosestVariantNode()\n if (closestVariantNode) {\n closestVariantNode.variantChildren &&\n closestVariantNode.variantChildren.add(child)\n return () => closestVariantNode.variantChildren!.delete(child)\n }\n }\n\n /**\n * Add a motion value and bind it to this visual element.\n */\n addValue(key: string, value: MotionValue) {\n // Remove existing value if it exists\n const existingValue = this.values.get(key)\n\n if (value !== existingValue) {\n if (existingValue) this.removeValue(key)\n this.bindToMotionValue(key, value)\n this.values.set(key, value)\n this.latestValues[key] = value.get()\n }\n }\n\n /**\n * Remove a motion value and unbind any active subscriptions.\n */\n removeValue(key: string) {\n this.values.delete(key)\n const unsubscribe = this.valueSubscriptions.get(key)\n if (unsubscribe) {\n unsubscribe()\n this.valueSubscriptions.delete(key)\n }\n delete this.latestValues[key]\n this.removeValueFromRenderState(key, this.renderState)\n }\n\n /**\n * Check whether we have a motion value for this key\n */\n hasValue(key: string) {\n return this.values.has(key)\n }\n\n /**\n * Get a motion value for this key. If called with a default\n * value, we'll create one if none exists.\n */\n getValue(key: string): MotionValue | undefined\n getValue(key: string, defaultValue: AnyResolvedKeyframe | null): MotionValue\n getValue(\n key: string,\n defaultValue?: AnyResolvedKeyframe | null\n ): MotionValue | undefined {\n if (this.props.values && this.props.values[key]) {\n return this.props.values[key]\n }\n\n let value = this.values.get(key)\n\n if (value === undefined && defaultValue !== undefined) {\n value = motionValue(\n defaultValue === null ? undefined : defaultValue,\n { owner: this }\n )\n this.addValue(key, value)\n }\n\n return value\n }\n\n /**\n * If we're trying to animate to a previously unencountered value,\n * we need to check for it in our state and as a last resort read it\n * directly from the instance (which might have performance implications).\n */\n readValue(key: string, target?: AnyResolvedKeyframe | null) {\n let value =\n this.latestValues[key] !== undefined || !this.current\n ? this.latestValues[key]\n : this.getBaseTargetFromProps(this.props, key) ??\n this.readValueFromInstance(this.current, key, this.options)\n\n if (value !== undefined && value !== null) {\n if (\n typeof value === \"string\" &&\n (isNumericalString(value) || isZeroValueString(value))\n ) {\n // If this is a number read as a string, ie \"0\" or \"200\", convert it to a number\n value = parseFloat(value)\n } else if (!findValueType(value) && complex.test(target)) {\n value = getAnimatableNone(key, target as string)\n }\n\n this.setBaseTarget(key, isMotionValue(value) ? value.get() : value)\n }\n\n return isMotionValue(value) ? value.get() : value\n }\n\n /**\n * Set the base target to later animate back to. This is currently\n * only hydrated on creation and when we first read a value.\n */\n setBaseTarget(key: string, value: AnyResolvedKeyframe) {\n this.baseTarget[key] = value\n }\n\n /**\n * Find the base target for a value thats been removed from all animation\n * props.\n */\n getBaseTarget(key: string): ResolvedValues[string] | undefined | null {\n const { initial } = this.props\n\n let valueFromInitial: ResolvedValues[string] | undefined | null\n\n if (typeof initial === \"string\" || typeof initial === \"object\") {\n const variant = resolveVariantFromProps(\n this.props,\n initial as any,\n this.presenceContext?.custom\n )\n if (variant) {\n valueFromInitial = variant[\n key as keyof typeof variant\n ] as string\n }\n }\n\n /**\n * If this value still exists in the current initial variant, read that.\n */\n if (initial && valueFromInitial !== undefined) {\n return valueFromInitial\n }\n\n /**\n * Alternatively, if this VisualElement config has defined a getBaseTarget\n * so we can read the value from an alternative source, try that.\n */\n const target = this.getBaseTargetFromProps(this.props, key)\n if (target !== undefined && !isMotionValue(target)) return target\n\n /**\n * If the value was initially defined on initial, but it doesn't any more,\n * return undefined. Otherwise return the value as initially read from the DOM.\n */\n return this.initialValues[key] !== undefined &&\n valueFromInitial === undefined\n ? undefined\n : this.baseTarget[key]\n }\n\n on<EventName extends keyof VisualElementEventCallbacks>(\n eventName: EventName,\n callback: VisualElementEventCallbacks[EventName]\n ) {\n if (!this.events[eventName]) {\n this.events[eventName] = new SubscriptionManager()\n }\n\n return this.events[eventName].add(callback)\n }\n\n notify<EventName extends keyof VisualElementEventCallbacks>(\n eventName: EventName,\n ...args: any\n ) {\n if (this.events[eventName]) {\n this.events[eventName].notify(...args)\n }\n }\n\n scheduleRenderMicrotask() {\n microtask.render(this.render)\n }\n}\n"],"names":["checkIsControllingVariants","checkIsVariantNode"],"mappings":";;;;;;;;;;;AAoDA,MAAM,iBAAiB,GAAG;IACtB,gBAAgB;IAChB,mBAAmB;IACnB,QAAQ;IACR,qBAAqB;IACrB,eAAe;IACf,sBAAsB;IACtB,yBAAyB;CACnB,CAAA;AAEV;;;AAGG;MACmB,aAAa,CAAA;AA2F/B;;;;;;AAMG;AACH,IAAA,2BAA2B,CACvB,MAAmB,EACnB,UAAuB,EACvB,cAA6B,EAAA;AAI7B,QAAA,OAAO,EAAE,CAAA;KACZ;AA2KD,IAAA,WAAA,CACI,EACI,MAAM,EACN,KAAK,EACL,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,GAC+B,EAC9C,UAAmB,EAAS,EAAA;AAlLhC;;;AAGG;QACH,IAAO,CAAA,OAAA,GAAoB,IAAI,CAAA;AAO/B;;AAEG;AACH,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,GAAG,EAAiB,CAAA;AAyBnC;;AAEG;QACH,IAAa,CAAA,aAAA,GAAY,KAAK,CAAA;QAC9B,IAAqB,CAAA,qBAAA,GAAY,KAAK,CAAA;AAStC;;;;;;AAMG;QACH,IAAkB,CAAA,kBAAA,GAAmB,IAAI,CAAA;AAuBzC;;;;AAIG;AACH,QAAA,IAAA,CAAA,MAAM,GAAG,IAAI,GAAG,EAAuB,CAAA;QAOvC,IAAgB,CAAA,gBAAA,GAAG,gBAAgB,CAAA;AAiBnC;;AAEG;QACK,IAAQ,CAAA,QAAA,GAEZ,EAAE,CAAA;AAEN;;;AAGG;AACK,QAAA,IAAA,CAAA,kBAAkB,GAAG,IAAI,GAAG,EAAwB,CAAA;AAa5D;;;;AAIG;QACK,IAAgB,CAAA,gBAAA,GAAgB,EAAE,CAAA;AA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AED;;;AAGG;AACH,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAC3D,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;AAAE,YAAA,OAAO,MAAM,CAAA;AAEjE;;;AAGG;AACH,QAAA,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,SAAS;AACxC,YAAA,gBAAgB,KAAK,SAAS;AAC9B,cAAE,SAAS;AACX,cAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;KAC7B;IAED,EAAE,CACE,SAAoB,EACpB,QAAgD,EAAA;QAEhD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YACzB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,mBAAmB,EAAE,CAAA;SACrD;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;KAC9C;AAED,IAAA,MAAM,CACF,SAAoB,EACpB,GAAG,IAAS,EAAA;AAEZ,QAAA,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;SACzC;KACJ;IAED,uBAAuB,GAAA;AACnB,QAAA,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;KAChC;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"VisualElement.mjs","sources":["../../../src/render/VisualElement.ts"],"sourcesContent":["import {\n cancelFrame,\n complex,\n findValueType,\n frame,\n getAnimatableNone,\n isMotionValue,\n KeyframeResolver,\n microtask,\n motionValue,\n time,\n transformProps,\n type AnyResolvedKeyframe,\n type MotionValue,\n} from \"motion-dom\"\nimport type { Box } from \"motion-utils\"\nimport {\n isNumericalString,\n isZeroValueString,\n SubscriptionManager,\n warnOnce,\n} from \"motion-utils\"\nimport {\n MotionConfigContext,\n ReducedMotionConfig,\n} from \"../context/MotionConfigContext\"\nimport type { PresenceContextProps } from \"../context/PresenceContext\"\nimport { featureDefinitions } from \"../motion/features/definitions\"\nimport { Feature } from \"../motion/features/Feature\"\nimport { FeatureDefinitions } from \"../motion/features/types\"\nimport { MotionProps, MotionStyle } from \"../motion/types\"\nimport { createBox } from \"../projection/geometry/models\"\nimport { IProjectionNode } from \"../projection/node/types\"\nimport { initPrefersReducedMotion } from \"../utils/reduced-motion\"\nimport {\n hasReducedMotionListener,\n prefersReducedMotion,\n} from \"../utils/reduced-motion/state\"\nimport { visualElementStore } from \"./store\"\nimport {\n ResolvedValues,\n VisualElementEventCallbacks,\n VisualElementOptions,\n} from \"./types\"\nimport { AnimationState } from \"./utils/animation-state\"\nimport {\n isControllingVariants as checkIsControllingVariants,\n isVariantNode as checkIsVariantNode,\n} from \"./utils/is-controlling-variants\"\nimport { updateMotionValuesFromProps } from \"./utils/motion-values\"\nimport { resolveVariantFromProps } from \"./utils/resolve-variants\"\n\nconst propEventHandlers = [\n \"AnimationStart\",\n \"AnimationComplete\",\n \"Update\",\n \"BeforeLayoutMeasure\",\n \"LayoutMeasure\",\n \"LayoutAnimationStart\",\n \"LayoutAnimationComplete\",\n] as const\n\n/**\n * A VisualElement is an imperative abstraction around UI elements such as\n * HTMLElement, SVGElement, Three.Object3D etc.\n */\nexport abstract class VisualElement<\n Instance = unknown,\n RenderState = unknown,\n Options extends {} = {}\n> {\n /**\n * VisualElements are arranged in trees mirroring that of the React tree.\n * Each type of VisualElement has a unique name, to detect when we're crossing\n * type boundaries within that tree.\n */\n abstract type: string\n\n /**\n * An `Array.sort` compatible function that will compare two Instances and\n * compare their respective positions within the tree.\n */\n abstract sortInstanceNodePosition(a: Instance, b: Instance): number\n\n /**\n * Measure the viewport-relative bounding box of the Instance.\n */\n abstract measureInstanceViewportBox(\n instance: Instance,\n props: MotionProps & Partial<MotionConfigContext>\n ): Box\n\n /**\n * When a value has been removed from all animation props we need to\n * pick a target to animate back to. For instance, for HTMLElements\n * we can look in the style prop.\n */\n abstract getBaseTargetFromProps(\n props: MotionProps,\n key: string\n ): AnyResolvedKeyframe | undefined | MotionValue\n\n /**\n * When we first animate to a value we need to animate it *from* a value.\n * Often this have been specified via the initial prop but it might be\n * that the value needs to be read from the Instance.\n */\n abstract readValueFromInstance(\n instance: Instance,\n key: string,\n options: Options\n ): AnyResolvedKeyframe | null | undefined\n\n /**\n * When a value has been removed from the VisualElement we use this to remove\n * it from the inherting class' unique render state.\n */\n abstract removeValueFromRenderState(\n key: string,\n renderState: RenderState\n ): void\n\n /**\n * Run before a React or VisualElement render, builds the latest motion\n * values into an Instance-specific format. For example, HTMLVisualElement\n * will use this step to build `style` and `var` values.\n */\n abstract build(\n renderState: RenderState,\n latestValues: ResolvedValues,\n props: MotionProps\n ): void\n\n /**\n * Apply the built values to the Instance. For example, HTMLElements will have\n * styles applied via `setProperty` and the style attribute, whereas SVGElements\n * will have values applied to attributes.\n */\n abstract renderInstance(\n instance: Instance,\n renderState: RenderState,\n styleProp?: MotionStyle,\n projection?: IProjectionNode\n ): void\n\n /**\n * This method is called when a transform property is bound to a motion value.\n * It's currently used to measure SVG elements when a new transform property is bound.\n */\n onBindTransform?(): void\n\n /**\n * If the component child is provided as a motion value, handle subscriptions\n * with the renderer-specific VisualElement.\n */\n handleChildMotionValue?(): void\n\n /**\n * This method takes React props and returns found MotionValues. For example, HTML\n * MotionValues will be found within the style prop, whereas for Three.js within attribute arrays.\n *\n * This isn't an abstract method as it needs calling in the constructor, but it is\n * intended to be one.\n */\n scrapeMotionValuesFromProps(\n _props: MotionProps,\n _prevProps: MotionProps,\n _visualElement: VisualElement\n ): {\n [key: string]: MotionValue | AnyResolvedKeyframe\n } {\n return {}\n }\n\n /**\n * A reference to the current underlying Instance, e.g. a HTMLElement\n * or Three.Mesh etc.\n */\n current: Instance | null = null\n\n /**\n * A reference to the parent VisualElement (if exists).\n */\n parent: VisualElement | undefined\n\n /**\n * A set containing references to this VisualElement's children.\n */\n children = new Set<VisualElement>()\n\n /**\n * A set containing the latest children of this VisualElement. This is flushed\n * at the start of every commit. We use it to calculate the stagger delay\n * for newly-added children.\n */\n enteringChildren?: Set<VisualElement>\n\n /**\n * The depth of this VisualElement within the overall VisualElement tree.\n */\n depth: number\n\n /**\n * The current render state of this VisualElement. Defined by inherting VisualElements.\n */\n renderState: RenderState\n\n /**\n * An object containing the latest static values for each of this VisualElement's\n * MotionValues.\n */\n latestValues: ResolvedValues\n\n /**\n * Determine what role this visual element should take in the variant tree.\n */\n isVariantNode: boolean = false\n isControllingVariants: boolean = false\n\n /**\n * If this component is part of the variant tree, it should track\n * any children that are also part of the tree. This is essentially\n * a shadow tree to simplify logic around how to stagger over children.\n */\n variantChildren?: Set<VisualElement>\n\n /**\n * Decides whether this VisualElement should animate in reduced motion\n * mode.\n *\n * TODO: This is currently set on every individual VisualElement but feels\n * like it could be set globally.\n */\n shouldReduceMotion: boolean | null = null\n\n /**\n * Normally, if a component is controlled by a parent's variants, it can\n * rely on that ancestor to trigger animations further down the tree.\n * However, if a component is created after its parent is mounted, the parent\n * won't trigger that mount animation so the child needs to.\n *\n * TODO: This might be better replaced with a method isParentMounted\n */\n manuallyAnimateOnMount: boolean\n\n /**\n * This can be set by AnimatePresence to force components that mount\n * at the same time as it to mount as if they have initial={false} set.\n */\n blockInitialAnimation: boolean\n\n /**\n * A reference to this VisualElement's projection node, used in layout animations.\n */\n projection?: IProjectionNode\n\n /**\n * A map of all motion values attached to this visual element. Motion\n * values are source of truth for any given animated value. A motion\n * value might be provided externally by the component via props.\n */\n values = new Map<string, MotionValue>()\n\n /**\n * The AnimationState, this is hydrated by the animation Feature.\n */\n animationState?: AnimationState\n\n KeyframeResolver = KeyframeResolver\n\n /**\n * The options used to create this VisualElement. The Options type is defined\n * by the inheriting VisualElement and is passed straight through to the render functions.\n */\n readonly options: Options\n\n /**\n * A reference to the latest props provided to the VisualElement's host React component.\n */\n props: MotionProps\n prevProps?: MotionProps\n\n presenceContext: PresenceContextProps | null\n prevPresenceContext?: PresenceContextProps | null\n\n /**\n * Cleanup functions for active features (hover/tap/exit etc)\n */\n private features: {\n [K in keyof FeatureDefinitions]?: Feature<Instance>\n } = {}\n\n /**\n * A map of every subscription that binds the provided or generated\n * motion values onChange listeners to this visual element.\n */\n private valueSubscriptions = new Map<string, VoidFunction>()\n\n /**\n * A reference to the ReducedMotionConfig passed to the VisualElement's host React component.\n */\n private reducedMotionConfig: ReducedMotionConfig | undefined\n\n /**\n * On mount, this will be hydrated with a callback to disconnect\n * this visual element from its parent on unmount.\n */\n private removeFromVariantTree: undefined | VoidFunction\n\n /**\n * A reference to the previously-provided motion values as returned\n * from scrapeMotionValuesFromProps. We use the keys in here to determine\n * if any motion values need to be removed after props are updated.\n */\n private prevMotionValues: MotionStyle = {}\n\n /**\n * When values are removed from all animation props we need to search\n * for a fallback value to animate to. These values are tracked in baseTarget.\n */\n private baseTarget: ResolvedValues\n\n /**\n * Create an object of the values we initially animated from (if initial prop present).\n */\n private initialValues: ResolvedValues\n\n /**\n * An object containing a SubscriptionManager for each active event.\n */\n private events: {\n [key: string]: SubscriptionManager<any>\n } = {}\n\n /**\n * An object containing an unsubscribe function for each prop event subscription.\n * For example, every \"Update\" event can have multiple subscribers via\n * VisualElement.on(), but only one of those can be defined via the onUpdate prop.\n */\n private propEventSubscriptions: {\n [key: string]: VoidFunction\n } = {}\n\n constructor(\n {\n parent,\n props,\n presenceContext,\n reducedMotionConfig,\n blockInitialAnimation,\n visualState,\n }: VisualElementOptions<Instance, RenderState>,\n options: Options = {} as any\n ) {\n const { latestValues, renderState } = visualState\n this.latestValues = latestValues\n this.baseTarget = { ...latestValues }\n this.initialValues = props.initial ? { ...latestValues } : {}\n this.renderState = renderState\n this.parent = parent\n this.props = props\n this.presenceContext = presenceContext\n this.depth = parent ? parent.depth + 1 : 0\n this.reducedMotionConfig = reducedMotionConfig\n this.options = options\n this.blockInitialAnimation = Boolean(blockInitialAnimation)\n\n this.isControllingVariants = checkIsControllingVariants(props)\n this.isVariantNode = checkIsVariantNode(props)\n if (this.isVariantNode) {\n this.variantChildren = new Set()\n }\n\n this.manuallyAnimateOnMount = Boolean(parent && parent.current)\n\n /**\n * Any motion values that are provided to the element when created\n * aren't yet bound to the element, as this would technically be impure.\n * However, we iterate through the motion values and set them to the\n * initial values for this component.\n *\n * TODO: This is impure and we should look at changing this to run on mount.\n * Doing so will break some tests but this isn't necessarily a breaking change,\n * more a reflection of the test.\n */\n const { willChange, ...initialMotionValues } =\n this.scrapeMotionValuesFromProps(props, {}, this)\n\n for (const key in initialMotionValues) {\n const value = initialMotionValues[key]\n\n if (latestValues[key] !== undefined && isMotionValue(value)) {\n value.set(latestValues[key])\n }\n }\n }\n\n mount(instance: Instance) {\n this.current = instance\n\n visualElementStore.set(instance, this)\n\n if (this.projection && !this.projection.instance) {\n this.projection.mount(instance)\n }\n\n if (this.parent && this.isVariantNode && !this.isControllingVariants) {\n this.removeFromVariantTree = this.parent.addVariantChild(this)\n }\n\n this.values.forEach((value, key) => this.bindToMotionValue(key, value))\n\n /**\n * Determine reduced motion preference. Only initialize the matchMedia\n * listener if we actually need the dynamic value (i.e., when config\n * is neither \"never\" nor \"always\").\n */\n if (this.reducedMotionConfig === \"never\") {\n this.shouldReduceMotion = false\n } else if (this.reducedMotionConfig === \"always\") {\n this.shouldReduceMotion = true\n } else {\n if (!hasReducedMotionListener.current) {\n initPrefersReducedMotion()\n }\n this.shouldReduceMotion = prefersReducedMotion.current\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n warnOnce(\n this.shouldReduceMotion !== true,\n \"You have Reduced Motion enabled on your device. Animations may not appear as expected.\",\n \"reduced-motion-disabled\"\n )\n }\n\n this.parent?.addChild(this)\n\n this.update(this.props, this.presenceContext)\n }\n\n unmount() {\n this.projection && this.projection.unmount()\n cancelFrame(this.notifyUpdate)\n cancelFrame(this.render)\n this.valueSubscriptions.forEach((remove) => remove())\n this.valueSubscriptions.clear()\n this.removeFromVariantTree && this.removeFromVariantTree()\n this.parent?.removeChild(this)\n\n for (const key in this.events) {\n this.events[key].clear()\n }\n\n for (const key in this.features) {\n const feature = this.features[key as keyof typeof this.features]\n if (feature) {\n feature.unmount()\n feature.isMounted = false\n }\n }\n this.current = null\n }\n\n addChild(child: VisualElement) {\n this.children.add(child)\n this.enteringChildren ??= new Set()\n this.enteringChildren.add(child)\n }\n\n removeChild(child: VisualElement) {\n this.children.delete(child)\n this.enteringChildren && this.enteringChildren.delete(child)\n }\n\n private bindToMotionValue(key: string, value: MotionValue) {\n if (this.valueSubscriptions.has(key)) {\n this.valueSubscriptions.get(key)!()\n }\n\n const valueIsTransform = transformProps.has(key)\n\n if (valueIsTransform && this.onBindTransform) {\n this.onBindTransform()\n }\n\n const removeOnChange = value.on(\n \"change\",\n (latestValue: AnyResolvedKeyframe) => {\n this.latestValues[key] = latestValue\n\n this.props.onUpdate && frame.preRender(this.notifyUpdate)\n\n if (valueIsTransform && this.projection) {\n this.projection.isTransformDirty = true\n }\n\n this.scheduleRender()\n }\n )\n\n let removeSyncCheck: VoidFunction | void\n if (window.MotionCheckAppearSync) {\n removeSyncCheck = window.MotionCheckAppearSync(this, key, value)\n }\n\n this.valueSubscriptions.set(key, () => {\n removeOnChange()\n if (removeSyncCheck) removeSyncCheck()\n if (value.owner) value.stop()\n })\n }\n\n sortNodePosition(other: VisualElement<Instance>) {\n /**\n * If these nodes aren't even of the same type we can't compare their depth.\n */\n if (\n !this.current ||\n !this.sortInstanceNodePosition ||\n this.type !== other.type\n ) {\n return 0\n }\n\n return this.sortInstanceNodePosition(\n this.current as Instance,\n other.current as Instance\n )\n }\n\n updateFeatures() {\n let key: keyof typeof featureDefinitions = \"animation\"\n\n for (key in featureDefinitions) {\n const featureDefinition = featureDefinitions[key]\n\n if (!featureDefinition) continue\n\n const { isEnabled, Feature: FeatureConstructor } = featureDefinition\n\n /**\n * If this feature is enabled but not active, make a new instance.\n */\n if (\n !this.features[key] &&\n FeatureConstructor &&\n isEnabled(this.props)\n ) {\n this.features[key] = new FeatureConstructor(this) as any\n }\n\n /**\n * If we have a feature, mount or update it.\n */\n if (this.features[key]) {\n const feature = this.features[key]!\n if (feature.isMounted) {\n feature.update()\n } else {\n feature.mount()\n feature.isMounted = true\n }\n }\n }\n }\n\n notifyUpdate = () => this.notify(\"Update\", this.latestValues)\n\n triggerBuild() {\n this.build(this.renderState, this.latestValues, this.props)\n }\n\n render = () => {\n if (!this.current) return\n this.triggerBuild()\n this.renderInstance(\n this.current,\n this.renderState,\n this.props.style,\n this.projection\n )\n }\n\n private renderScheduledAt = 0.0\n scheduleRender = () => {\n const now = time.now()\n if (this.renderScheduledAt < now) {\n this.renderScheduledAt = now\n frame.render(this.render, false, true)\n }\n }\n\n /**\n * Measure the current viewport box with or without transforms.\n * Only measures axis-aligned boxes, rotate and skew must be manually\n * removed with a re-render to work.\n */\n measureViewportBox() {\n return this.current\n ? this.measureInstanceViewportBox(this.current, this.props)\n : createBox()\n }\n\n getStaticValue(key: string) {\n return this.latestValues[key]\n }\n\n setStaticValue(key: string, value: AnyResolvedKeyframe) {\n this.latestValues[key] = value\n }\n\n /**\n * Update the provided props. Ensure any newly-added motion values are\n * added to our map, old ones removed, and listeners updated.\n */\n update(props: MotionProps, presenceContext: PresenceContextProps | null) {\n if (props.transformTemplate || this.props.transformTemplate) {\n this.scheduleRender()\n }\n\n this.prevProps = this.props\n this.props = props\n\n this.prevPresenceContext = this.presenceContext\n this.presenceContext = presenceContext\n\n /**\n * Update prop event handlers ie onAnimationStart, onAnimationComplete\n */\n for (let i = 0; i < propEventHandlers.length; i++) {\n const key = propEventHandlers[i]\n if (this.propEventSubscriptions[key]) {\n this.propEventSubscriptions[key]()\n delete this.propEventSubscriptions[key]\n }\n\n const listenerName = (\"on\" + key) as keyof typeof props\n const listener = props[listenerName]\n if (listener) {\n this.propEventSubscriptions[key] = this.on(key as any, listener)\n }\n }\n\n this.prevMotionValues = updateMotionValuesFromProps(\n this,\n this.scrapeMotionValuesFromProps(props, this.prevProps, this),\n this.prevMotionValues\n )\n\n if (this.handleChildMotionValue) {\n this.handleChildMotionValue()\n }\n }\n\n getProps() {\n return this.props\n }\n\n /**\n * Returns the variant definition with a given name.\n */\n getVariant(name: string) {\n return this.props.variants ? this.props.variants[name] : undefined\n }\n\n /**\n * Returns the defined default transition on this component.\n */\n getDefaultTransition() {\n return this.props.transition\n }\n\n getTransformPagePoint() {\n return (this.props as any).transformPagePoint\n }\n\n getClosestVariantNode(): VisualElement | undefined {\n return this.isVariantNode\n ? this\n : this.parent\n ? this.parent.getClosestVariantNode()\n : undefined\n }\n\n /**\n * Add a child visual element to our set of children.\n */\n addVariantChild(child: VisualElement) {\n const closestVariantNode = this.getClosestVariantNode()\n if (closestVariantNode) {\n closestVariantNode.variantChildren &&\n closestVariantNode.variantChildren.add(child)\n return () => closestVariantNode.variantChildren!.delete(child)\n }\n }\n\n /**\n * Add a motion value and bind it to this visual element.\n */\n addValue(key: string, value: MotionValue) {\n // Remove existing value if it exists\n const existingValue = this.values.get(key)\n\n if (value !== existingValue) {\n if (existingValue) this.removeValue(key)\n this.bindToMotionValue(key, value)\n this.values.set(key, value)\n this.latestValues[key] = value.get()\n }\n }\n\n /**\n * Remove a motion value and unbind any active subscriptions.\n */\n removeValue(key: string) {\n this.values.delete(key)\n const unsubscribe = this.valueSubscriptions.get(key)\n if (unsubscribe) {\n unsubscribe()\n this.valueSubscriptions.delete(key)\n }\n delete this.latestValues[key]\n this.removeValueFromRenderState(key, this.renderState)\n }\n\n /**\n * Check whether we have a motion value for this key\n */\n hasValue(key: string) {\n return this.values.has(key)\n }\n\n /**\n * Get a motion value for this key. If called with a default\n * value, we'll create one if none exists.\n */\n getValue(key: string): MotionValue | undefined\n getValue(key: string, defaultValue: AnyResolvedKeyframe | null): MotionValue\n getValue(\n key: string,\n defaultValue?: AnyResolvedKeyframe | null\n ): MotionValue | undefined {\n if (this.props.values && this.props.values[key]) {\n return this.props.values[key]\n }\n\n let value = this.values.get(key)\n\n if (value === undefined && defaultValue !== undefined) {\n value = motionValue(\n defaultValue === null ? undefined : defaultValue,\n { owner: this }\n )\n this.addValue(key, value)\n }\n\n return value\n }\n\n /**\n * If we're trying to animate to a previously unencountered value,\n * we need to check for it in our state and as a last resort read it\n * directly from the instance (which might have performance implications).\n */\n readValue(key: string, target?: AnyResolvedKeyframe | null) {\n let value =\n this.latestValues[key] !== undefined || !this.current\n ? this.latestValues[key]\n : this.getBaseTargetFromProps(this.props, key) ??\n this.readValueFromInstance(this.current, key, this.options)\n\n if (value !== undefined && value !== null) {\n if (\n typeof value === \"string\" &&\n (isNumericalString(value) || isZeroValueString(value))\n ) {\n // If this is a number read as a string, ie \"0\" or \"200\", convert it to a number\n value = parseFloat(value)\n } else if (!findValueType(value) && complex.test(target)) {\n value = getAnimatableNone(key, target as string)\n }\n\n this.setBaseTarget(key, isMotionValue(value) ? value.get() : value)\n }\n\n return isMotionValue(value) ? value.get() : value\n }\n\n /**\n * Set the base target to later animate back to. This is currently\n * only hydrated on creation and when we first read a value.\n */\n setBaseTarget(key: string, value: AnyResolvedKeyframe) {\n this.baseTarget[key] = value\n }\n\n /**\n * Find the base target for a value thats been removed from all animation\n * props.\n */\n getBaseTarget(key: string): ResolvedValues[string] | undefined | null {\n const { initial } = this.props\n\n let valueFromInitial: ResolvedValues[string] | undefined | null\n\n if (typeof initial === \"string\" || typeof initial === \"object\") {\n const variant = resolveVariantFromProps(\n this.props,\n initial as any,\n this.presenceContext?.custom\n )\n if (variant) {\n valueFromInitial = variant[\n key as keyof typeof variant\n ] as string\n }\n }\n\n /**\n * If this value still exists in the current initial variant, read that.\n */\n if (initial && valueFromInitial !== undefined) {\n return valueFromInitial\n }\n\n /**\n * Alternatively, if this VisualElement config has defined a getBaseTarget\n * so we can read the value from an alternative source, try that.\n */\n const target = this.getBaseTargetFromProps(this.props, key)\n if (target !== undefined && !isMotionValue(target)) return target\n\n /**\n * If the value was initially defined on initial, but it doesn't any more,\n * return undefined. Otherwise return the value as initially read from the DOM.\n */\n return this.initialValues[key] !== undefined &&\n valueFromInitial === undefined\n ? undefined\n : this.baseTarget[key]\n }\n\n on<EventName extends keyof VisualElementEventCallbacks>(\n eventName: EventName,\n callback: VisualElementEventCallbacks[EventName]\n ) {\n if (!this.events[eventName]) {\n this.events[eventName] = new SubscriptionManager()\n }\n\n return this.events[eventName].add(callback)\n }\n\n notify<EventName extends keyof VisualElementEventCallbacks>(\n eventName: EventName,\n ...args: any\n ) {\n if (this.events[eventName]) {\n this.events[eventName].notify(...args)\n }\n }\n\n scheduleRenderMicrotask() {\n microtask.render(this.render)\n }\n}\n"],"names":["checkIsControllingVariants","checkIsVariantNode"],"mappings":";;;;;;;;;;;AAoDA,MAAM,iBAAiB,GAAG;IACtB,gBAAgB;IAChB,mBAAmB;IACnB,QAAQ;IACR,qBAAqB;IACrB,eAAe;IACf,sBAAsB;IACtB,yBAAyB;CACnB,CAAA;AAEV;;;AAGG;MACmB,aAAa,CAAA;AA2F/B;;;;;;AAMG;AACH,IAAA,2BAA2B,CACvB,MAAmB,EACnB,UAAuB,EACvB,cAA6B,EAAA;AAI7B,QAAA,OAAO,EAAE,CAAA;KACZ;AA2KD,IAAA,WAAA,CACI,EACI,MAAM,EACN,KAAK,EACL,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,GAC+B,EAC9C,UAAmB,EAAS,EAAA;AAlLhC;;;AAGG;QACH,IAAO,CAAA,OAAA,GAAoB,IAAI,CAAA;AAO/B;;AAEG;AACH,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,GAAG,EAAiB,CAAA;AAyBnC;;AAEG;QACH,IAAa,CAAA,aAAA,GAAY,KAAK,CAAA;QAC9B,IAAqB,CAAA,qBAAA,GAAY,KAAK,CAAA;AAStC;;;;;;AAMG;QACH,IAAkB,CAAA,kBAAA,GAAmB,IAAI,C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AAC,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;SACzC;KACJ;IAED,uBAAuB,GAAA;AACnB,QAAA,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;KAChC;AACJ;;;;"}
|
|
@@ -5436,6 +5436,10 @@
|
|
|
5436
5436
|
* Track which exiting children have finished animating out.
|
|
5437
5437
|
*/
|
|
5438
5438
|
const exitComplete = useConstant(() => new Map());
|
|
5439
|
+
/**
|
|
5440
|
+
* Track which components are currently processing exit to prevent duplicate processing.
|
|
5441
|
+
*/
|
|
5442
|
+
const exitingComponents = React$1.useRef(new Set());
|
|
5439
5443
|
/**
|
|
5440
5444
|
* Save children to render as React state. To ensure this component is concurrent-safe,
|
|
5441
5445
|
* we check for exiting children via an effect.
|
|
@@ -5457,6 +5461,7 @@
|
|
|
5457
5461
|
}
|
|
5458
5462
|
else {
|
|
5459
5463
|
exitComplete.delete(key);
|
|
5464
|
+
exitingComponents.current.delete(key);
|
|
5460
5465
|
}
|
|
5461
5466
|
}
|
|
5462
5467
|
}, [renderedChildren, presentKeys.length, presentKeys.join("-")]);
|
|
@@ -5507,6 +5512,10 @@
|
|
|
5507
5512
|
: presentChildren === renderedChildren ||
|
|
5508
5513
|
presentKeys.includes(key);
|
|
5509
5514
|
const onExit = () => {
|
|
5515
|
+
if (exitingComponents.current.has(key)) {
|
|
5516
|
+
return;
|
|
5517
|
+
}
|
|
5518
|
+
exitingComponents.current.add(key);
|
|
5510
5519
|
if (exitComplete.has(key)) {
|
|
5511
5520
|
exitComplete.set(key, true);
|
|
5512
5521
|
}
|
|
@@ -8424,15 +8433,23 @@
|
|
|
8424
8433
|
this.removeFromVariantTree = this.parent.addVariantChild(this);
|
|
8425
8434
|
}
|
|
8426
8435
|
this.values.forEach((value, key) => this.bindToMotionValue(key, value));
|
|
8427
|
-
|
|
8428
|
-
|
|
8436
|
+
/**
|
|
8437
|
+
* Determine reduced motion preference. Only initialize the matchMedia
|
|
8438
|
+
* listener if we actually need the dynamic value (i.e., when config
|
|
8439
|
+
* is neither "never" nor "always").
|
|
8440
|
+
*/
|
|
8441
|
+
if (this.reducedMotionConfig === "never") {
|
|
8442
|
+
this.shouldReduceMotion = false;
|
|
8443
|
+
}
|
|
8444
|
+
else if (this.reducedMotionConfig === "always") {
|
|
8445
|
+
this.shouldReduceMotion = true;
|
|
8446
|
+
}
|
|
8447
|
+
else {
|
|
8448
|
+
if (!hasReducedMotionListener.current) {
|
|
8449
|
+
initPrefersReducedMotion();
|
|
8450
|
+
}
|
|
8451
|
+
this.shouldReduceMotion = prefersReducedMotion.current;
|
|
8429
8452
|
}
|
|
8430
|
-
this.shouldReduceMotion =
|
|
8431
|
-
this.reducedMotionConfig === "never"
|
|
8432
|
-
? false
|
|
8433
|
-
: this.reducedMotionConfig === "always"
|
|
8434
|
-
? true
|
|
8435
|
-
: prefersReducedMotion.current;
|
|
8436
8453
|
{
|
|
8437
8454
|
warnOnce(this.shouldReduceMotion !== true, "You have Reduced Motion enabled on your device. Animations may not appear as expected.", "reduced-motion-disabled");
|
|
8438
8455
|
}
|