summit/frontend/node_modules/@react-spring/animated/dist/react-spring_animated.moder...

1 line
20 KiB
Plaintext
Raw Normal View History

2025-12-08 16:31:30 +00:00
{"version":3,"sources":["../src/Animated.ts","../src/AnimatedValue.ts","../src/AnimatedString.ts","../src/AnimatedArray.ts","../src/AnimatedObject.ts","../src/context.ts","../src/getAnimatedType.ts","../src/createHost.ts","../src/withAnimated.tsx"],"sourcesContent":["import { defineHidden } from '@react-spring/shared'\nimport { AnimatedValue } from './AnimatedValue'\n\nconst $node: any = Symbol.for('Animated:node')\n\nexport const isAnimated = <T = any>(value: any): value is Animated<T> =>\n !!value && value[$node] === value\n\n/** Get the owner's `Animated` node. */\nexport const getAnimated = <T = any>(owner: any): Animated<T> | undefined =>\n owner && owner[$node]\n\n/** Set the owner's `Animated` node. */\nexport const setAnimated = (owner: any, node: Animated) =>\n defineHidden(owner, $node, node)\n\n/** Get every `AnimatedValue` in the owner's `Animated` node. */\nexport const getPayload = (owner: any): AnimatedValue[] | undefined =>\n owner && owner[$node] && owner[$node].getPayload()\n\nexport abstract class Animated<T = any> {\n /** The cache of animated values */\n protected payload?: Payload\n\n constructor() {\n // This makes \"isAnimated\" return true.\n setAnimated(this, this)\n }\n\n /** Get the current value. Pass `true` for only animated values. */\n abstract getValue(animated?: boolean): T\n\n /** Set the current value. Returns `true` if the value changed. */\n abstract setValue(value: T): boolean | void\n\n /** Reset any animation state. */\n abstract reset(goal?: T): void\n\n /** Get every `AnimatedValue` used by this node. */\n getPayload(): Payload {\n return this.payload || []\n }\n}\n\nexport type Payload = readonly AnimatedValue[]\n","import { is } from '@react-spring/shared'\nimport { Animated, Payload } from './Animated'\n\n/** An animated number or a native attribute value */\nexport class AnimatedValue<T = any> extends Animated {\n done = true\n elapsedTime!: number\n lastPosition!: number\n lastVelocity?: number | null\n v0?: number | null\n durationProgress = 0\n\n constructor(protected _value: T) {\n super()\n if (is.num(this._value)) {\n this.lastPosition = this._value\n }\n }\n\n /** @internal */\n static create(value: any) {\n return new AnimatedValue(value)\n }\n\n getPayload(): Payload {\n return [this]\n }\n\n getValue() {\n return this._value\n }\n\n setValue(value: T, step?: number) {\n if (is.num(value)) {\n this.lastPosition = value\n if (step) {\n value = (Math.round(value / step) * step) as any\n if (this.done) {\n this.lastPosition = value as any\n }\n }\n }\n if (this._value === value) {\n return false\n }\n this._value = value\n return true\n }\n\n reset() {\n const { done } = this\n this.done = false\n if (is.num(this._value)) {\n this.elapsedTime = 0\n this.durationProgress = 0\n this.lastPosition = this._value\n if (done) this.lastVelocity = null\n this.v0 = null\n }\n }\n}\n","import { AnimatedValue } from './AnimatedValue'\nimport { is, createInterpolator } from '@react-spring/shared'\n\ntype Value = string | number\n\nexport class AnimatedString extends AnimatedValue<Value> {\n protected declare _value: number\n protected _string: string | null = null\n protected _toString: (input: number) => string\n\n constructor(value: string) {\n super(0)\n this._toString = createInterpolator({\n output: [value, value],\n })\n }\n\n /** @internal */\n static create(value: string) {\n return new AnimatedString(value)\n }\n\n getValue() {\n const value = this._string\n return value == null ? (this._string = this._toString(this._value)) : value\n }\n\n setValue(value: Value) {\n if (is.str(value)) {\n if (value == this._string) {\n return false\n }\n this._string = value\n this._value = 1\n } else if (super.setValue(value)) {\n this._string = null\n } else {\n return false\n }\n return true\n }\n\n reset(goal?: string) {\n i