motion-dom 14.12.0 → 14.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +275 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/generators/spring.mjs +3 -3
- package/dist/es/animation/generators/spring.mjs.map +1 -1
- package/dist/es/gestures/pinch/index.mjs +2 -3
- package/dist/es/gestures/pinch/index.mjs.map +1 -1
- package/dist/es/index.mjs +1 -1
- package/dist/es/projection/animation/layout-velocity.mjs +28 -0
- package/dist/es/projection/animation/layout-velocity.mjs.map +1 -0
- package/dist/es/projection/node/create-projection-node.mjs +251 -7
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/index.d.ts +92 -6
- package/dist/motion-dom.dev.js +275 -11
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-pinch.js +1 -1
- package/dist/size-rollup-pinch.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2096,6 +2096,20 @@ interface MotionNodeAdvancedOptions {
|
|
|
2096
2096
|
* @public
|
|
2097
2097
|
*/
|
|
2098
2098
|
transformTemplate?: TransformTemplate;
|
|
2099
|
+
/**
|
|
2100
|
+
* Draw this element on its own in the canvas of an `<FX>` it's
|
|
2101
|
+
* inside, at any depth, so it can have effects. Direct children of a
|
|
2102
|
+
* `<FX>` are drawn without it.
|
|
2103
|
+
*
|
|
2104
|
+
* ```jsx
|
|
2105
|
+
* <FX shaders={[motionBlur()]}>
|
|
2106
|
+
* <ul>
|
|
2107
|
+
* <motion.li fx animate={{ x: 300 }} />
|
|
2108
|
+
* </ul>
|
|
2109
|
+
* </FX>
|
|
2110
|
+
* ```
|
|
2111
|
+
*/
|
|
2112
|
+
fx?: boolean;
|
|
2099
2113
|
"data-framer-appear-id"?: string;
|
|
2100
2114
|
}
|
|
2101
2115
|
interface PropagateOptions {
|
|
@@ -2720,11 +2734,14 @@ interface SpringOptions extends DurationSpringOptions, VelocityOptions {
|
|
|
2720
2734
|
* Mass of the moving object. Higher values will result in more lethargic
|
|
2721
2735
|
* movement. Set to `1` by default.
|
|
2722
2736
|
*
|
|
2737
|
+
* In layout animations, `"auto"` sets mass from the element's size, so
|
|
2738
|
+
* bigger elements move heavier.
|
|
2739
|
+
*
|
|
2723
2740
|
* @default 1
|
|
2724
2741
|
*
|
|
2725
2742
|
* @public
|
|
2726
2743
|
*/
|
|
2727
|
-
mass?: number;
|
|
2744
|
+
mass?: number | "auto";
|
|
2728
2745
|
}
|
|
2729
2746
|
/**
|
|
2730
2747
|
* @deprecated Use SpringOptions instead
|
|
@@ -3850,6 +3867,19 @@ declare function inertia({ keyframes, velocity, power, timeConstant, bounceDampi
|
|
|
3850
3867
|
declare function defaultEasing(values: any[], easing?: EasingFunction): EasingFunction[];
|
|
3851
3868
|
declare function keyframes<T extends AnyResolvedKeyframe>({ duration, keyframes: keyframeValues, times, ease, mixer: transitionMixer, }: ValueAnimationOptions<T>): KeyframeGenerator<T>;
|
|
3852
3869
|
|
|
3870
|
+
declare function getSpringOptions(options: SpringOptions): {
|
|
3871
|
+
stiffness: number;
|
|
3872
|
+
damping: number;
|
|
3873
|
+
mass: number;
|
|
3874
|
+
isResolvedFromDuration: boolean;
|
|
3875
|
+
isTimeDefined: boolean;
|
|
3876
|
+
duration?: number | undefined;
|
|
3877
|
+
visualDuration?: number | undefined;
|
|
3878
|
+
bounce?: number | undefined;
|
|
3879
|
+
velocity?: number | undefined;
|
|
3880
|
+
restSpeed?: number | undefined;
|
|
3881
|
+
restDelta?: number | undefined;
|
|
3882
|
+
};
|
|
3853
3883
|
declare function springGenerator(optionsOrVisualDuration?: ValueAnimationOptions<number> | number, bounce?: number): KeyframeGenerator<number>;
|
|
3854
3884
|
declare const spring: typeof springGenerator & {
|
|
3855
3885
|
applyToOptions: (options: Transition) => Transition;
|
|
@@ -4267,6 +4297,15 @@ interface Measurements {
|
|
|
4267
4297
|
layoutBox: Box;
|
|
4268
4298
|
latestValues: ResolvedValues$1;
|
|
4269
4299
|
source: number;
|
|
4300
|
+
/**
|
|
4301
|
+
* Velocity (px/s) when measured, for the next spring layout animation.
|
|
4302
|
+
* velocity is [x min, x max, y min, y max, x value, y value] in the
|
|
4303
|
+
* page, and is only set when something moves. relativeVelocity is
|
|
4304
|
+
* [x min, x max, y min, y max] inside the parent, for a child that was
|
|
4305
|
+
* moving inside an animating parent.
|
|
4306
|
+
*/
|
|
4307
|
+
velocity?: number[];
|
|
4308
|
+
relativeVelocity?: number[];
|
|
4270
4309
|
}
|
|
4271
4310
|
type Phase = "snapshot" | "measure";
|
|
4272
4311
|
interface ScrollMeasurements {
|
|
@@ -4354,7 +4393,12 @@ interface IProjectionNode<I = unknown> {
|
|
|
4354
4393
|
resetTree(): void;
|
|
4355
4394
|
isProjecting(): boolean;
|
|
4356
4395
|
animationValues?: ResolvedValues$1;
|
|
4357
|
-
currentAnimation?:
|
|
4396
|
+
currentAnimation?: AnimationPlaybackControls;
|
|
4397
|
+
/**
|
|
4398
|
+
* The latest offsets (px) of the x min, x max, y min and y max edge
|
|
4399
|
+
* springs, while a layout animation runs with velocity.
|
|
4400
|
+
*/
|
|
4401
|
+
edgeValues?: number[];
|
|
4358
4402
|
isTreeAnimating?: boolean;
|
|
4359
4403
|
isAnimationBlocked?: boolean;
|
|
4360
4404
|
setAnimationOrigin(delta: Delta, hasOnlyRelativeTargetChanged?: boolean, pathFn?: MotionPath): void;
|
|
@@ -6233,9 +6277,33 @@ declare function createProjectionNode<I>({ attachResizeListener, defaultParent,
|
|
|
6233
6277
|
*/
|
|
6234
6278
|
animationValues?: ResolvedValues$1 | undefined;
|
|
6235
6279
|
pendingAnimation?: Process | undefined;
|
|
6236
|
-
currentAnimation?:
|
|
6280
|
+
currentAnimation?: AnimationPlaybackControls | undefined;
|
|
6237
6281
|
mixTargetDelta: (progress: number) => void;
|
|
6238
6282
|
animationProgress: number;
|
|
6283
|
+
/**
|
|
6284
|
+
* Layout velocity.
|
|
6285
|
+
* animationEdges are the offsets (px) of the x min, x max, y min and
|
|
6286
|
+
* y max edges from the layout at the start of the animation.
|
|
6287
|
+
* startVelocity is for the next animation: one progress velocity for
|
|
6288
|
+
* a curved path, or a velocity (px/s) for each edge.
|
|
6289
|
+
* edgeValues hold the latest edge offsets while each edge runs on
|
|
6290
|
+
* its own spring, and edgeVelocity reads an edge's velocity.
|
|
6291
|
+
*/
|
|
6292
|
+
animationEdges?: number[] | undefined;
|
|
6293
|
+
startVelocity?: number | number[] | undefined;
|
|
6294
|
+
edgeValues?: number[] | undefined;
|
|
6295
|
+
edgeVelocity?: ((i: number) => number) | undefined;
|
|
6296
|
+
/**
|
|
6297
|
+
* relativeVelocity is measured each frame while a child moves inside
|
|
6298
|
+
* its parent. relativeStart is the relative velocity of the next
|
|
6299
|
+
* animation, and impulse is how far one px/s of it has moved the
|
|
6300
|
+
* child so far.
|
|
6301
|
+
*/
|
|
6302
|
+
relativeVelocity?: number[] | undefined;
|
|
6303
|
+
relativeTime?: number | undefined;
|
|
6304
|
+
relativeStart?: number[] | undefined;
|
|
6305
|
+
impulse?: number | undefined;
|
|
6306
|
+
isSpringLayout?: boolean | undefined;
|
|
6239
6307
|
setAnimationOrigin(delta: Delta, hasOnlyRelativeTargetChanged?: boolean, pathFn?: MotionPath): void;
|
|
6240
6308
|
motionValue?: MotionValue<number> | undefined;
|
|
6241
6309
|
startAnimation(options: ValueAnimationOptions<number>): void;
|
|
@@ -6385,9 +6453,18 @@ declare const DocumentProjectionNode: {
|
|
|
6385
6453
|
createProjectionDeltas(): void;
|
|
6386
6454
|
animationValues?: ResolvedValues$1 | undefined;
|
|
6387
6455
|
pendingAnimation?: Process | undefined;
|
|
6388
|
-
currentAnimation?:
|
|
6456
|
+
currentAnimation?: AnimationPlaybackControls | undefined;
|
|
6389
6457
|
mixTargetDelta: (progress: number) => void;
|
|
6390
6458
|
animationProgress: number;
|
|
6459
|
+
animationEdges?: number[] | undefined;
|
|
6460
|
+
startVelocity?: number | number[] | undefined;
|
|
6461
|
+
edgeValues?: number[] | undefined;
|
|
6462
|
+
edgeVelocity?: ((i: number) => number) | undefined;
|
|
6463
|
+
relativeVelocity?: number[] | undefined;
|
|
6464
|
+
relativeTime?: number | undefined;
|
|
6465
|
+
relativeStart?: number[] | undefined;
|
|
6466
|
+
impulse?: number | undefined;
|
|
6467
|
+
isSpringLayout?: boolean | undefined;
|
|
6391
6468
|
setAnimationOrigin(delta: motion_utils.Delta, hasOnlyRelativeTargetChanged?: boolean, pathFn?: MotionPath | undefined): void;
|
|
6392
6469
|
motionValue?: MotionValue<number> | undefined;
|
|
6393
6470
|
startAnimation(options: ValueAnimationOptions<number>): void;
|
|
@@ -6530,9 +6607,18 @@ declare const HTMLProjectionNode: {
|
|
|
6530
6607
|
createProjectionDeltas(): void;
|
|
6531
6608
|
animationValues?: ResolvedValues$1 | undefined;
|
|
6532
6609
|
pendingAnimation?: Process | undefined;
|
|
6533
|
-
currentAnimation?:
|
|
6610
|
+
currentAnimation?: AnimationPlaybackControls | undefined;
|
|
6534
6611
|
mixTargetDelta: (progress: number) => void;
|
|
6535
6612
|
animationProgress: number;
|
|
6613
|
+
animationEdges?: number[] | undefined;
|
|
6614
|
+
startVelocity?: number | number[] | undefined;
|
|
6615
|
+
edgeValues?: number[] | undefined;
|
|
6616
|
+
edgeVelocity?: ((i: number) => number) | undefined;
|
|
6617
|
+
relativeVelocity?: number[] | undefined;
|
|
6618
|
+
relativeTime?: number | undefined;
|
|
6619
|
+
relativeStart?: number[] | undefined;
|
|
6620
|
+
impulse?: number | undefined;
|
|
6621
|
+
isSpringLayout?: boolean | undefined;
|
|
6536
6622
|
setAnimationOrigin(delta: motion_utils.Delta, hasOnlyRelativeTargetChanged?: boolean, pathFn?: MotionPath | undefined): void;
|
|
6537
6623
|
motionValue?: MotionValue<number> | undefined;
|
|
6538
6624
|
startAnimation(options: ValueAnimationOptions<number>): void;
|
|
@@ -6652,4 +6738,4 @@ declare const sync: Batcher;
|
|
|
6652
6738
|
*/
|
|
6653
6739
|
declare const cancelSync: Record<string, (process: Process) => void>;
|
|
6654
6740
|
|
|
6655
|
-
export { type AccelerateConfig, type AcceptedAnimations, type ActiveStatsBuffer, type AddEffectValue, type AnimateEffect, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationList, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState$1 as AnimationState, type AnimationType, type AnimationTypeState, type AnyResolvedKeyframe, type ArcOptions, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, DOMVisualElement, type DOMVisualElementOptions, type DecayOptions, type DelayedFunction, DocumentProjectionNode, type DragConstraintsContext, type DragConstraintsFunction, type DragControlOptions, type DragElastic, type DragHandler, type DragOptions, type DragPointConstraint, type DraggableProps, type DurationSpringOptions, type DynamicOption, type Effect, type EffectKeyframes, type EffectOptions, type EffectRead, type EffectTest, type EffectTransition, type ElementOrSelector, type EventInfo, type EventListenerWithPointInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, HTMLProjectionNode, type HTMLRenderState, HTMLVisualElement, type HandoffFunction, type IProjectionNode, type InactiveStatsBuffer, type InertiaOptions, type InitialPromotionConfig, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, LayoutAnimationBuilder, type LayoutEvents, type LayoutLifecycles, type LayoutProjectionMetrics, type LayoutProjectionStats, type LayoutUpdateData, type LayoutUpdateHandler, type LegacyAnimationControls, type MapInputRange, type Measurements, type MediaConditions, type Mixer, type MixerFactory, type MotionConfigContextProps, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, type MotionPath, type MotionScope, type MotionStyle, MotionValue, type MotionValueAnimation, type MotionValueEventCallbacks, type MotionValueOptions, MotionValueState, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NodeGroup, NodeStack, type NumberMap, ObjectVisualElement, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPinchEvent, type OnPinchStartEvent, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, PanSession, type PassiveEffect, type PathInterpolator, type PathState, type Phase, type PinchHandlers, type PinchInfo, type PinchLimits, type PinchOptions, type PinchProps, type PinchRotateOptions, type PinchValues, type Point2D, type PointerEventOptions, type PresenceContextProps, type PressGestureInfo, type PressHandlers, type PressOptions, type Process, type ProgressTimeline, type ProjectionEventName, type ProjectionNodeConfig, type ProjectionNodeOptions, type PropagateOptions, type RGBA, type ReducedMotionConfig, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues$1 as ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGRenderState, type SVGTransitions, SVGVisualElement, type ScaleCorrectionNode, type ScaleCorrector, type ScaleCorrectorDefinition, type ScaleCorrectorMap, type Schedule, type ScopeOptions, type ScopeSetup, type ScopeState, type ScrapeMotionValuesFromProps, type ScrollMeasurements, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type StatsRecording, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleSubject, type StyleTransitions, type Subscriber, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformOrigin, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type UseRenderState, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, VisualElement, type VisualElementAnimationOptions, VisualElementDragControls, type VisualElementEventCallbacks, type VisualElementOptions, type VisualState, type WillChange, type WithAppearProps, type WithDepth, type WithQuerySelectorAll, acceleratedValues, acquireProjectionNode, activeScope, addAttrValue, addBuilderToScope, addDomEvent, addEffect, addPinchListeners, addPointerEvent, addPointerInfo, addSVGValue, addScaleCorrector, addStyleValue, addToScope, addValueToWillChange, alpha, analyseComplexValue, animateEffectSubject, animateElement, animateLayout, animateMotionValue, animateSingleValue, animateTarget, animateValue, animateValues, animateVariant, animateView, animateVisualElement, animationMapKey, applyAxisDelta, applyBoxDelta, applyGeneratorOptions, applyPointDelta, applyPxDefaults, applyTreeDeltas, arc, aspectRatio, attachFollow, attachSpring, attrEffect, axisDeltaEquals, axisEquals, axisEqualsRounded, bindToScope, boxEquals, boxEqualsRounded, buildHTMLStyles, buildProjectionTransform, buildSVGAttrs, buildSVGPath, buildTransform, buildTransformer, calcAxisDelta, calcBoxDelta, calcChildStagger, calcGeneratorDuration, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, camelCaseAttributes, camelToDash, cancelFrame, cancelMicrotask, cancelSync, checkVariantsDidChange, cleanDirtyNodes, collectMotionValues, color, compareByDepth, complex, containsCSSVariable, convertBoundingBoxToBox, convertBoxToBoundingBox, convertOffsetToTimes, copyAxisDeltaInto, copyAxisInto, copyBoxInto, correctBorderRadius, correctBoxShadow, createAnimationState, createAxis, createAxisDelta, createBox, createDelta, createEffect, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, distance, distance2D, drag, eachAxis, elementDragControls, expectsResolvedDragConstraints, extractEventInfo, fillOffset, fillWildcards, findDimensionValueType, findEffect, findValueType, flushKeyframeResolvers, flushLayoutSnapshots, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, handOffElementState, has2DTranslate, hasComplexValues, hasReducedMotionListener, hasScale, hasTransform, hex, hover, hsla, hslaToRgba, inertia, initPrefersReducedMotion, interpolate, invisibleValues, isAnimationControls, isCSSVariableName, isCSSVariableToken, isControllingVariants, isDeltaZero, isDragActive, isDragging, isElementKeyboardAccessible, isElementTextInput, isForcedMotionValue, isGenerator, isHTMLElement, isKeyframesTarget, isMotionValue, isNear, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isSVGTag, isTransitionDefined, isVariantLabel, isVariantNode, isWaapiSupportedEasing, isWillChangeMotionValue, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, measurePageBox, measureViewportBox, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixValues, mixVisibility, motionValue, nodeGroup, number, numberValueTypes, optimizedAppearDataAttribute, optimizedAppearDataId, originProps, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pinch, pixelsToPercent, positionalKeys, prefersReducedMotion, press, processFrame, progressPercentage, propEffect, propagateDirtyNodes, px, readSVGValue, readStyleValue, readTransformValue, recordStats, releaseElement, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removeEffect, removePointDelta, renderHTML, renderSVG, resize, resolveElements, resolveMotionValue, resolveTransition, resolveVariant, resolveVariantFromProps, rgbUnit, rgba, rootProjectionNode, round, sampleDelta, scale, scaleCorrectors, scalePoint, scopeMotion, scrapeMotionValuesFromProps$1 as scrapeHTMLMotionValuesFromProps, scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps, setDragLock, setFeatureDefinitions, setStyle, setTarget, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, styleSubjectEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, supportsViewTimeline, supportsWaapi, svgEffect, svgSubjectEffect, sync, testValueType, time, toMediaQuery, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };
|
|
6741
|
+
export { type AccelerateConfig, type AcceptedAnimations, type ActiveStatsBuffer, type AddEffectValue, type AnimateEffect, type AnimationDefinition, type AnimationGeneratorName, type AnimationGeneratorType, type AnimationList, type AnimationOptions, type AnimationOrchestrationOptions, type AnimationPlaybackControls, type AnimationPlaybackControlsWithThen, type AnimationPlaybackLifecycles, type AnimationPlaybackOptions, type AnimationScope, type AnimationState$1 as AnimationState, type AnimationType, type AnimationTypeState, type AnyResolvedKeyframe, type ArcOptions, AsyncMotionValueAnimation, type Batcher, type CSSStyleDeclarationWithTransform, type CSSVariableName, type CSSVariableToken, type CancelProcess, type Color, type ComplexValueInfo, type ComplexValues, type DOMKeyframesDefinition, DOMKeyframesResolver, type DOMValueAnimationOptions, DOMVisualElement, type DOMVisualElementOptions, type DecayOptions, type DelayedFunction, DocumentProjectionNode, type DragConstraintsContext, type DragConstraintsFunction, type DragControlOptions, type DragElastic, type DragHandler, type DragOptions, type DragPointConstraint, type DraggableProps, type DurationSpringOptions, type DynamicOption, type Effect, type EffectKeyframes, type EffectOptions, type EffectRead, type EffectTest, type EffectTransition, type ElementOrSelector, type EventInfo, type EventListenerWithPointInfo, type EventOptions, Feature, type FeatureClass, FlatTree, type FollowValueOptions, type FrameData, type GeneratorFactory, type GeneratorFactoryFunction, GroupAnimation, GroupAnimationWithThen, type GroupedAnimations, type HSLA, HTMLProjectionNode, type HTMLRenderState, HTMLVisualElement, type HandoffFunction, type IProjectionNode, type InactiveStatsBuffer, type InertiaOptions, type InitialPromotionConfig, type InterpolateOptions, JSAnimation, type KeyframeGenerator, type KeyframeOptions, KeyframeResolver, LayoutAnimationBuilder, type LayoutEvents, type LayoutLifecycles, type LayoutProjectionMetrics, type LayoutProjectionStats, type LayoutUpdateData, type LayoutUpdateHandler, type LegacyAnimationControls, type MapInputRange, type Measurements, type MediaConditions, type Mixer, type MixerFactory, type MotionConfigContextProps, type MotionNodeAdvancedOptions, type MotionNodeAnimationOptions, type MotionNodeDragHandlers, type MotionNodeDraggableOptions, type MotionNodeEventOptions, type MotionNodeFocusHandlers, type MotionNodeHoverHandlers, type MotionNodeLayoutOptions, type MotionNodeOptions, type MotionNodePanHandlers, type MotionNodeTapHandlers, type MotionNodeViewportOptions, type MotionPath, type MotionScope, type MotionStyle, MotionValue, type MotionValueAnimation, type MotionValueEventCallbacks, type MotionValueOptions, MotionValueState, type MultiTransformer, NativeAnimation, NativeAnimationExtended, type NativeAnimationOptions, type NativeAnimationOptionsExtended, NativeAnimationWrapper, type NodeGroup, NodeStack, type NumberMap, ObjectVisualElement, type OnHoverEndEvent, type OnHoverStartEvent, type OnKeyframesResolved, type OnPinchEvent, type OnPinchStartEvent, type OnPressEndEvent, type OnPressStartEvent, type Owner, type PanHandler, type PanInfo, PanSession, type PassiveEffect, type PathInterpolator, type PathState, type Phase, type PinchHandlers, type PinchInfo, type PinchLimits, type PinchOptions, type PinchProps, type PinchRotateOptions, type PinchValues, type Point2D, type PointerEventOptions, type PresenceContextProps, type PressGestureInfo, type PressHandlers, type PressOptions, type Process, type ProgressTimeline, type ProjectionEventName, type ProjectionNodeConfig, type ProjectionNodeOptions, type PropagateOptions, type RGBA, type ReducedMotionConfig, type RepeatType, type ResolvedConstraints, type ResolvedElastic, type ResolvedKeyframes, type ResolvedValueKeyframe, type ResolvedValues$1 as ResolvedValues, type SVGAttributes, type SVGForcedAttrKeyframesDefinition, type SVGForcedAttrProperties, type SVGForcedAttrTransitions, type SVGKeyframesDefinition, type SVGPathKeyframesDefinition, type SVGPathProperties, type SVGPathTransitions, type SVGRenderState, type SVGTransitions, SVGVisualElement, type ScaleCorrectionNode, type ScaleCorrector, type ScaleCorrectorDefinition, type ScaleCorrectorMap, type Schedule, type ScopeOptions, type ScopeSetup, type ScopeState, type ScrapeMotionValuesFromProps, type ScrollMeasurements, type SelectorCache, type SingleTransformer, type Spring, type SpringOptions, type StaggerOptions, type StaggerOrigin, type StartAnimation, type StatsRecording, type Step, type StepId, type Steps, type StyleKeyframesDefinition, type StyleSubject, type StyleTransitions, type Subscriber, type TapHandlers, type TapInfo, type Target, type TargetAndTransition, type TargetResolver, type TimelineWithFallback, type TransformInputRange, type TransformOptions, type TransformOrigin, type TransformProperties, type TransformTemplate, type Transformer, type Transition, type TransitionWithValueOverrides, type Tween, type UnresolvedKeyframes, type UnresolvedValueKeyframe, type UseRenderState, type ValueAnimationOptions, type ValueAnimationOptionsWithRenderContext, type ValueAnimationTransition, type ValueAnimationWithDynamicDelay, type ValueIndexes, type ValueKeyframe, type ValueKeyframesDefinition, type ValueTransformer, type ValueTransition, type ValueType, type ValueTypeMap, type VariableKeyframesDefinition, type VariableTransitions, type Variant, type VariantLabels, type Variants, type VelocityOptions, type ViewTransitionAnimationDefinition, ViewTransitionBuilder, type ViewTransitionOptions, type ViewTransitionTarget, type ViewTransitionTargetDefinition, type ViewportEventHandler, type ViewportOptions, VisualElement, type VisualElementAnimationOptions, VisualElementDragControls, type VisualElementEventCallbacks, type VisualElementOptions, type VisualState, type WillChange, type WithAppearProps, type WithDepth, type WithQuerySelectorAll, acceleratedValues, acquireProjectionNode, activeScope, addAttrValue, addBuilderToScope, addDomEvent, addEffect, addPinchListeners, addPointerEvent, addPointerInfo, addSVGValue, addScaleCorrector, addStyleValue, addToScope, addValueToWillChange, alpha, analyseComplexValue, animateEffectSubject, animateElement, animateLayout, animateMotionValue, animateSingleValue, animateTarget, animateValue, animateValues, animateVariant, animateView, animateVisualElement, animationMapKey, applyAxisDelta, applyBoxDelta, applyGeneratorOptions, applyPointDelta, applyPxDefaults, applyTreeDeltas, arc, aspectRatio, attachFollow, attachSpring, attrEffect, axisDeltaEquals, axisEquals, axisEqualsRounded, bindToScope, boxEquals, boxEqualsRounded, buildHTMLStyles, buildProjectionTransform, buildSVGAttrs, buildSVGPath, buildTransform, buildTransformer, calcAxisDelta, calcBoxDelta, calcChildStagger, calcGeneratorDuration, calcLength, calcRelativeAxis, calcRelativeAxisPosition, calcRelativeBox, calcRelativePosition, camelCaseAttributes, camelToDash, cancelFrame, cancelMicrotask, cancelSync, checkVariantsDidChange, cleanDirtyNodes, collectMotionValues, color, compareByDepth, complex, containsCSSVariable, convertBoundingBoxToBox, convertBoxToBoundingBox, convertOffsetToTimes, copyAxisDeltaInto, copyAxisInto, copyBoxInto, correctBorderRadius, correctBoxShadow, createAnimationState, createAxis, createAxisDelta, createBox, createDelta, createEffect, createGeneratorEasing, createProjectionNode, createRenderBatcher, cubicBezierAsString, defaultEasing, defaultOffset, defaultTransformValue, defaultValueTypes, degrees, delay, delayInSeconds, dimensionValueTypes, distance, distance2D, drag, eachAxis, elementDragControls, expectsResolvedDragConstraints, extractEventInfo, fillOffset, fillWildcards, findDimensionValueType, findEffect, findValueType, flushKeyframeResolvers, flushLayoutSnapshots, followValue, frame, frameData, frameSteps, generateLinearEasing, getAnimatableNone, getAnimationMap, getComputedStyle, getDefaultTransition, getDefaultValueType, getFeatureDefinitions, getFinalKeyframe, getMixer, getOptimisedAppearId, getOriginIndex, getSpringOptions, getValueAsType, getValueTransition, getVariableValue, getVariantContext, getViewAnimationLayerInfo, getViewAnimations, globalProjectionState, handOffElementState, has2DTranslate, hasComplexValues, hasReducedMotionListener, hasScale, hasTransform, hex, hover, hsla, hslaToRgba, inertia, initPrefersReducedMotion, interpolate, invisibleValues, isAnimationControls, isCSSVariableName, isCSSVariableToken, isControllingVariants, isDeltaZero, isDragActive, isDragging, isElementKeyboardAccessible, isElementTextInput, isForcedMotionValue, isGenerator, isHTMLElement, isKeyframesTarget, isMotionValue, isNear, isNodeOrChild, isPrimaryPointer, isSVGElement, isSVGSVGElement, isSVGTag, isTransitionDefined, isVariantLabel, isVariantNode, isWaapiSupportedEasing, isWillChangeMotionValue, keyframes, makeAnimationInstant, mapEasingToNativeEasing, mapValue, maxGeneratorDuration, measurePageBox, measureViewportBox, microtask, mix, mixArray, mixColor, mixComplex, mixImmediate, mixLinearColor, mixNumber, mixObject, mixValues, mixVisibility, motionValue, nodeGroup, number, numberValueTypes, optimizedAppearDataAttribute, optimizedAppearDataId, originProps, parseAnimateLayoutArgs, parseCSSVariable, parseValueFromTransform, percent, pinch, pixelsToPercent, positionalKeys, prefersReducedMotion, press, processFrame, progressPercentage, propEffect, propagateDirtyNodes, px, readSVGValue, readStyleValue, readTransformValue, recordStats, releaseElement, removeAxisDelta, removeAxisTransforms, removeBoxTransforms, removeEffect, removePointDelta, renderHTML, renderSVG, resize, resolveElements, resolveMotionValue, resolveTransition, resolveVariant, resolveVariantFromProps, rgbUnit, rgba, rootProjectionNode, round, sampleDelta, scale, scaleCorrectors, scalePoint, scopeMotion, scrapeMotionValuesFromProps$1 as scrapeHTMLMotionValuesFromProps, scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps, setDragLock, setFeatureDefinitions, setStyle, setTarget, spring, springValue, stagger, startWaapiAnimation, statsBuffer, styleEffect, styleSubjectEffect, supportedWaapiEasing, supportsBrowserAnimation, supportsFlags, supportsLinearEasing, supportsPartialKeyframes, supportsScrollTimeline, supportsViewTimeline, supportsWaapi, svgEffect, svgSubjectEffect, sync, testValueType, time, toMediaQuery, transform, transformAxis, transformBox, transformBoxPoints, transformPropOrder, transformProps, transformValue, transformValueTypes, translateAxis, updateMotionValuesFromProps, variantPriorityOrder, variantProps, vh, visualElementStore, vw };
|
package/dist/motion-dom.dev.js
CHANGED
|
@@ -972,7 +972,7 @@
|
|
|
972
972
|
if (isValidPhysics(value, canBeZero))
|
|
973
973
|
return value;
|
|
974
974
|
{
|
|
975
|
-
motionUtils.warning(value === undefined, "Spring stiffness and mass must be positive, damping 0 or greater", "spring-invalid-physics");
|
|
975
|
+
motionUtils.warning(value === undefined || value === "auto", "Spring stiffness and mass must be positive, damping 0 or greater", "spring-invalid-physics");
|
|
976
976
|
}
|
|
977
977
|
return undefined;
|
|
978
978
|
}
|
|
@@ -7318,6 +7318,29 @@
|
|
|
7318
7318
|
};
|
|
7319
7319
|
}
|
|
7320
7320
|
|
|
7321
|
+
/**
|
|
7322
|
+
* A curved path ties x and y to one progress value, so it takes the part of
|
|
7323
|
+
* the velocity along the straight line from start to end.
|
|
7324
|
+
*/
|
|
7325
|
+
const pointToProgressVelocity = (tx, ty, { x, y }) => {
|
|
7326
|
+
const lengthSquared = tx * tx + ty * ty;
|
|
7327
|
+
return lengthSquared < 1 ? 0 : (-1e3 * (x * tx + y * ty)) / lengthSquared;
|
|
7328
|
+
};
|
|
7329
|
+
/**
|
|
7330
|
+
* With `mass: "auto"`, mass comes from the element's size: a 300px square
|
|
7331
|
+
* has mass 1, bigger elements are heavier and slower (mass 0.25 to 2), and
|
|
7332
|
+
* damping scales with mass so the spring keeps its bounce. The result is a
|
|
7333
|
+
* physics spring.
|
|
7334
|
+
*/
|
|
7335
|
+
const resolveAutoMass = (t, size = 300) => {
|
|
7336
|
+
const mass = motionUtils.clamp(0.25, 2, size / 300);
|
|
7337
|
+
const { stiffness, damping } = getSpringOptions({
|
|
7338
|
+
...t,
|
|
7339
|
+
duration: t.duration && motionUtils.secondsToMilliseconds(t.duration),
|
|
7340
|
+
});
|
|
7341
|
+
return { ...t, stiffness, damping: damping * Math.sqrt(mass), mass };
|
|
7342
|
+
};
|
|
7343
|
+
|
|
7321
7344
|
/**
|
|
7322
7345
|
* Reset an axis to the provided origin box.
|
|
7323
7346
|
*
|
|
@@ -8413,6 +8436,37 @@
|
|
|
8413
8436
|
!calcLength(this.snapshot.measuredBox.y)) {
|
|
8414
8437
|
this.snapshot = undefined;
|
|
8415
8438
|
}
|
|
8439
|
+
/**
|
|
8440
|
+
* Record how fast the element is moving when it's measured, so
|
|
8441
|
+
* the next layout animation can start at the same speed.
|
|
8442
|
+
*/
|
|
8443
|
+
if (this.snapshot) {
|
|
8444
|
+
const { visualElement } = this.options;
|
|
8445
|
+
/**
|
|
8446
|
+
* A paused or stopped animation hands on no velocity.
|
|
8447
|
+
*/
|
|
8448
|
+
const isRunning = this.currentAnimation?.state === "running";
|
|
8449
|
+
const edges = isRunning && this.animationEdges;
|
|
8450
|
+
/**
|
|
8451
|
+
* A child moving inside its parent hands on only its
|
|
8452
|
+
* velocity relative to the parent.
|
|
8453
|
+
*/
|
|
8454
|
+
if (isRunning && this.relativeTarget) {
|
|
8455
|
+
this.snapshot.relativeVelocity =
|
|
8456
|
+
this.relativeVelocity?.slice() || [];
|
|
8457
|
+
}
|
|
8458
|
+
const progress = (edges && this.motionValue?.getVelocity()) || 0;
|
|
8459
|
+
const velocity = [0, 1, 2, 3, 4, 5].map((i) => (i < 4
|
|
8460
|
+
? edges &&
|
|
8461
|
+
(this.edgeValues
|
|
8462
|
+
? this.edgeVelocity(i)
|
|
8463
|
+
: (-edges[i] * progress) / 1000)
|
|
8464
|
+
: visualElement
|
|
8465
|
+
?.getValue(i < 5 ? "x" : "y")
|
|
8466
|
+
?.getVelocity()) || 0);
|
|
8467
|
+
if (velocity.some(Boolean))
|
|
8468
|
+
this.snapshot.velocity = velocity;
|
|
8469
|
+
}
|
|
8416
8470
|
}
|
|
8417
8471
|
updateLayout() {
|
|
8418
8472
|
if (!this.instance)
|
|
@@ -8938,11 +8992,62 @@
|
|
|
8938
8992
|
// The path decides whether the layout shift is worth curving
|
|
8939
8993
|
// (distance floor) and resolves the interpolator from the delta.
|
|
8940
8994
|
const interpolate = pathFn?.interpolateProjection(delta);
|
|
8995
|
+
const box = this.layout?.layoutBox;
|
|
8996
|
+
let edges = box &&
|
|
8997
|
+
[box.x.min, box.x.max, box.y.min, box.y.max].map((edge, i) => {
|
|
8998
|
+
const { translate, scale, originPoint } = delta[i < 2 ? "x" : "y"];
|
|
8999
|
+
return (edge - originPoint) * (scale - 1) + translate;
|
|
9000
|
+
});
|
|
9001
|
+
/**
|
|
9002
|
+
* A zero-length layout axis has no finite edge offsets.
|
|
9003
|
+
*/
|
|
9004
|
+
if (!edges?.every(isFinite))
|
|
9005
|
+
edges = undefined;
|
|
9006
|
+
this.animationEdges = edges;
|
|
9007
|
+
this.edgeValues =
|
|
9008
|
+
this.startVelocity =
|
|
9009
|
+
this.impulse =
|
|
9010
|
+
this.relativeVelocity =
|
|
9011
|
+
this.relativeStart =
|
|
9012
|
+
undefined;
|
|
9013
|
+
/**
|
|
9014
|
+
* A shared snapshot is measured with the old element's own
|
|
9015
|
+
* transforms (like x/y from drag), so it hands their velocity on
|
|
9016
|
+
* too. Otherwise those values keep animating themselves.
|
|
9017
|
+
*/
|
|
9018
|
+
const velocity = snapshot?.velocity;
|
|
9019
|
+
/**
|
|
9020
|
+
* A child that wasn't moving inside an animating parent before
|
|
9021
|
+
* moved in page space, so that is its relative velocity.
|
|
9022
|
+
*/
|
|
9023
|
+
const relative = snapshot?.relativeVelocity || velocity;
|
|
9024
|
+
if (relative?.slice(0, 4).some(Boolean) &&
|
|
9025
|
+
this.getClosestProjectingParent()) {
|
|
9026
|
+
this.relativeStart = relative;
|
|
9027
|
+
}
|
|
9028
|
+
if (velocity && edges) {
|
|
9029
|
+
const v = velocity
|
|
9030
|
+
.slice(0, 4)
|
|
9031
|
+
.map((edge, i) => edge +
|
|
9032
|
+
(isSharedLayoutAnimation
|
|
9033
|
+
? velocity[4 + (i >> 1)]
|
|
9034
|
+
: 0));
|
|
9035
|
+
if (v.some(Boolean)) {
|
|
9036
|
+
this.startVelocity = interpolate
|
|
9037
|
+
? pointToProgressVelocity(delta.x.translate, delta.y.translate, { x: (v[0] + v[1]) / 2, y: (v[2] + v[3]) / 2 })
|
|
9038
|
+
: v;
|
|
9039
|
+
}
|
|
9040
|
+
}
|
|
8941
9041
|
this.mixTargetDelta = (latest) => {
|
|
8942
9042
|
const progress = latest / 1000;
|
|
8943
9043
|
const point = interpolate?.(progress);
|
|
8944
|
-
|
|
8945
|
-
|
|
9044
|
+
const values = this.edgeValues;
|
|
9045
|
+
for (let i = 0; i < 2; i++) {
|
|
9046
|
+
const axis = i ? "y" : "x";
|
|
9047
|
+
values
|
|
9048
|
+
? edgesToDelta(targetDelta[axis], delta[axis], this.layout.layoutBox[axis], values[i * 2], values[i * 2 + 1])
|
|
9049
|
+
: mixAxisDeltaLinear(targetDelta[axis], delta[axis], progress);
|
|
9050
|
+
}
|
|
8946
9051
|
if (point) {
|
|
8947
9052
|
targetDelta.x.translate = point.x;
|
|
8948
9053
|
targetDelta.y.translate = point.y;
|
|
@@ -8954,7 +9059,41 @@
|
|
|
8954
9059
|
this.relativeParent &&
|
|
8955
9060
|
this.relativeParent.layout) {
|
|
8956
9061
|
calcRelativePosition(relativeLayout, this.layout.layoutBox, this.relativeParent.layout.layoutBox, this.options.layoutAnchor || undefined);
|
|
8957
|
-
|
|
9062
|
+
const from = this.relativeTargetOrigin;
|
|
9063
|
+
const to = relativeLayout;
|
|
9064
|
+
/**
|
|
9065
|
+
* A child mixes its place in its parent by progress,
|
|
9066
|
+
* so a nested tree moves as one.
|
|
9067
|
+
*/
|
|
9068
|
+
mixBox(this.relativeTarget, from, to, progress);
|
|
9069
|
+
/**
|
|
9070
|
+
* Springs are linear, so the child's own velocity adds
|
|
9071
|
+
* the impulse response on top of the mix.
|
|
9072
|
+
*/
|
|
9073
|
+
/**
|
|
9074
|
+
* Only springs take velocity, so a tween skips this.
|
|
9075
|
+
*/
|
|
9076
|
+
if (this.isSpringLayout) {
|
|
9077
|
+
const box = this.relativeTarget;
|
|
9078
|
+
const impulse = this.impulse || 0;
|
|
9079
|
+
const start = this.relativeStart;
|
|
9080
|
+
const now = time.now();
|
|
9081
|
+
const dt = (now - this.relativeTime) / 1000;
|
|
9082
|
+
this.relativeTime = now;
|
|
9083
|
+
const speeds = (this.relativeVelocity || (this.relativeVelocity = [0, 0, 0, 0]));
|
|
9084
|
+
for (let i = 0; i < 4; i++) {
|
|
9085
|
+
const axis = i < 2 ? "x" : "y";
|
|
9086
|
+
const edge = i & 1 ? "max" : "min";
|
|
9087
|
+
if (start)
|
|
9088
|
+
box[axis][edge] += start[i] * impulse;
|
|
9089
|
+
if (prevRelativeTarget && dt > 0) {
|
|
9090
|
+
speeds[i] =
|
|
9091
|
+
(box[axis][edge] -
|
|
9092
|
+
prevRelativeTarget[axis][edge]) /
|
|
9093
|
+
dt;
|
|
9094
|
+
}
|
|
9095
|
+
}
|
|
9096
|
+
}
|
|
8958
9097
|
/**
|
|
8959
9098
|
* If this is an unchanged relative target we can consider the
|
|
8960
9099
|
* projection not dirty.
|
|
@@ -8986,8 +9125,11 @@
|
|
|
8986
9125
|
}
|
|
8987
9126
|
startAnimation(options) {
|
|
8988
9127
|
this.notifyListeners("animationStart");
|
|
9128
|
+
const isSpring = (this.isSpringLayout = options.type === "spring");
|
|
8989
9129
|
this.currentAnimation?.stop();
|
|
8990
9130
|
this.resumingFrom?.currentAnimation?.stop();
|
|
9131
|
+
if (this.resumingFrom)
|
|
9132
|
+
this.resumingFrom.edgeValues = undefined;
|
|
8991
9133
|
if (this.pendingAnimation) {
|
|
8992
9134
|
cancelFrame(this.pendingAnimation);
|
|
8993
9135
|
this.pendingAnimation = undefined;
|
|
@@ -9001,9 +9143,114 @@
|
|
|
9001
9143
|
globalProjectionState.hasAnimatedSinceResize = true;
|
|
9002
9144
|
this.motionValue || (this.motionValue = motionValue(0));
|
|
9003
9145
|
this.motionValue.jump(0, false);
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9146
|
+
/**
|
|
9147
|
+
* A duration spring ignores velocity, like in animate(), so
|
|
9148
|
+
* it ends on time.
|
|
9149
|
+
*/
|
|
9150
|
+
const velocity = this.startVelocity;
|
|
9151
|
+
this.startVelocity = undefined;
|
|
9152
|
+
let transition = options;
|
|
9153
|
+
let mainVelocity = 0;
|
|
9154
|
+
if (isSpring) {
|
|
9155
|
+
/**
|
|
9156
|
+
* With mass: "auto", mass comes from the element's own
|
|
9157
|
+
* size.
|
|
9158
|
+
*/
|
|
9159
|
+
if (options.mass === "auto") {
|
|
9160
|
+
const box = this.layout?.layoutBox;
|
|
9161
|
+
transition = resolveAutoMass(options, box &&
|
|
9162
|
+
Math.sqrt(calcLength(box.x) * calcLength(box.y)));
|
|
9163
|
+
}
|
|
9164
|
+
/**
|
|
9165
|
+
* Only springs take a velocity. A tween keeps one
|
|
9166
|
+
* driver, so its controls (pause, time) reach it all.
|
|
9167
|
+
*/
|
|
9168
|
+
const relative = this.relativeStart;
|
|
9169
|
+
if ((velocity || relative) && !options.repeat) {
|
|
9170
|
+
if (typeof velocity === "number") {
|
|
9171
|
+
mainVelocity = velocity;
|
|
9172
|
+
}
|
|
9173
|
+
else {
|
|
9174
|
+
/**
|
|
9175
|
+
* Each edge (x min, x max, y min, y max) gets its
|
|
9176
|
+
* own spring in pixels, with its own start
|
|
9177
|
+
* velocity. An edge that doesn't move keeps
|
|
9178
|
+
* still, and a thrown element keeps its size.
|
|
9179
|
+
* One generator steps them all with the main
|
|
9180
|
+
* spring, so one animation drives them and its
|
|
9181
|
+
* controls reach them all.
|
|
9182
|
+
*/
|
|
9183
|
+
const edges = velocity && this.animationEdges;
|
|
9184
|
+
transition = {
|
|
9185
|
+
...transition,
|
|
9186
|
+
type: (o) => {
|
|
9187
|
+
const springs = [
|
|
9188
|
+
o.velocity,
|
|
9189
|
+
...(velocity || []),
|
|
9190
|
+
].map((v, i) => spring({
|
|
9191
|
+
...o,
|
|
9192
|
+
keyframes: i
|
|
9193
|
+
? [edges[i - 1], 0]
|
|
9194
|
+
: o.keyframes,
|
|
9195
|
+
velocity: v,
|
|
9196
|
+
}));
|
|
9197
|
+
const count = springs.length;
|
|
9198
|
+
/**
|
|
9199
|
+
* The response to 1000 px/s, for a
|
|
9200
|
+
* child's velocity inside its parent.
|
|
9201
|
+
* Coarse rest thresholds, because a
|
|
9202
|
+
* small offset of it is far below 1px.
|
|
9203
|
+
*/
|
|
9204
|
+
relative &&
|
|
9205
|
+
springs.push(spring({
|
|
9206
|
+
...o,
|
|
9207
|
+
keyframes: [0, 0],
|
|
9208
|
+
velocity: 1000,
|
|
9209
|
+
restDelta: 0.5,
|
|
9210
|
+
restSpeed: 5,
|
|
9211
|
+
}));
|
|
9212
|
+
let time = 0;
|
|
9213
|
+
const values = [];
|
|
9214
|
+
const generator = {
|
|
9215
|
+
calculatedDuration: null,
|
|
9216
|
+
next: (t) => {
|
|
9217
|
+
time = t;
|
|
9218
|
+
const state = springs[0].next(t);
|
|
9219
|
+
let done = state.done;
|
|
9220
|
+
for (let i = 1; i < springs.length; i++) {
|
|
9221
|
+
const { value, done: rest } = springs[i].next(t);
|
|
9222
|
+
if (i < count) {
|
|
9223
|
+
values[i - 1] = value;
|
|
9224
|
+
}
|
|
9225
|
+
else {
|
|
9226
|
+
this.impulse = value / 1000;
|
|
9227
|
+
}
|
|
9228
|
+
done = done && rest;
|
|
9229
|
+
}
|
|
9230
|
+
if (edges)
|
|
9231
|
+
this.edgeValues = values;
|
|
9232
|
+
state.done = done;
|
|
9233
|
+
return state;
|
|
9234
|
+
},
|
|
9235
|
+
};
|
|
9236
|
+
/**
|
|
9237
|
+
* Measure the duration now, then go back
|
|
9238
|
+
* to the start, so a delay shows the
|
|
9239
|
+
* start and not the end.
|
|
9240
|
+
*/
|
|
9241
|
+
generator.calculatedDuration =
|
|
9242
|
+
calcGeneratorDuration(generator);
|
|
9243
|
+
generator.next(0);
|
|
9244
|
+
this.edgeVelocity = (i) => springs[i + 1].velocity(time);
|
|
9245
|
+
return generator;
|
|
9246
|
+
},
|
|
9247
|
+
};
|
|
9248
|
+
}
|
|
9249
|
+
}
|
|
9250
|
+
}
|
|
9251
|
+
const main = animateSingleValue(this.motionValue, [0, 1000], {
|
|
9252
|
+
...transition,
|
|
9253
|
+
velocity: mainVelocity,
|
|
9007
9254
|
isSync: true,
|
|
9008
9255
|
onUpdate: (latest) => {
|
|
9009
9256
|
this.mixTargetDelta(latest);
|
|
@@ -9014,6 +9261,7 @@
|
|
|
9014
9261
|
this.completeAnimation();
|
|
9015
9262
|
},
|
|
9016
9263
|
});
|
|
9264
|
+
this.currentAnimation = main;
|
|
9017
9265
|
notifyLayoutAnimationStart(this.currentAnimation, this);
|
|
9018
9266
|
if (this.resumingFrom) {
|
|
9019
9267
|
this.resumingFrom.currentAnimation = this.currentAnimation;
|
|
@@ -9031,11 +9279,15 @@
|
|
|
9031
9279
|
this.resumingFrom =
|
|
9032
9280
|
this.currentAnimation =
|
|
9033
9281
|
this.animationValues =
|
|
9034
|
-
|
|
9282
|
+
this.edgeValues =
|
|
9283
|
+
this.edgeVelocity =
|
|
9284
|
+
this.impulse =
|
|
9285
|
+
undefined;
|
|
9035
9286
|
this.notifyListeners("animationComplete");
|
|
9036
9287
|
}
|
|
9037
9288
|
finishAnimation() {
|
|
9038
9289
|
if (this.currentAnimation) {
|
|
9290
|
+
this.edgeValues = this.impulse = undefined;
|
|
9039
9291
|
this.mixTargetDelta?.(animationTarget);
|
|
9040
9292
|
this.currentAnimation.stop();
|
|
9041
9293
|
}
|
|
@@ -9531,6 +9783,18 @@
|
|
|
9531
9783
|
function resetSkewAndRotation(node) {
|
|
9532
9784
|
node.resetSkewAndRotation();
|
|
9533
9785
|
}
|
|
9786
|
+
/**
|
|
9787
|
+
* Build an axis delta that moves the layout's edges by these offsets (px).
|
|
9788
|
+
*/
|
|
9789
|
+
function edgesToDelta(output, delta, layout, min, max) {
|
|
9790
|
+
const length = layout.max - layout.min;
|
|
9791
|
+
const scale = length ? Math.max(0, (length + max - min) / length) : 1;
|
|
9792
|
+
const origin = (output.originPoint = delta.originPoint);
|
|
9793
|
+
output.origin = delta.origin;
|
|
9794
|
+
output.scale = scale;
|
|
9795
|
+
output.translate =
|
|
9796
|
+
layout.min + min - (origin + (layout.min - origin) * scale);
|
|
9797
|
+
}
|
|
9534
9798
|
function mixAxisDeltaLinear(output, delta, p) {
|
|
9535
9799
|
output.translate = mixNumber$1(delta.translate, 0, p);
|
|
9536
9800
|
output.scale = mixNumber$1(delta.scale, 1, p);
|
|
@@ -12412,15 +12676,14 @@
|
|
|
12412
12676
|
* step and the focal point stays in place.
|
|
12413
12677
|
*/
|
|
12414
12678
|
const tick = () => {
|
|
12415
|
-
if (dragControls()?.isDragging)
|
|
12416
|
-
return stopSnap();
|
|
12417
12679
|
const { value: p, done } = generator.next(time.now() - startTime);
|
|
12418
12680
|
if (done)
|
|
12419
12681
|
stopSnap();
|
|
12420
12682
|
const [k, r, fx, fy] = at(p);
|
|
12421
12683
|
scaleOption !== false && scale.set(k);
|
|
12422
12684
|
rotateOption !== false && rotate.set(r);
|
|
12423
|
-
|
|
12685
|
+
// A drag that starts mid-snap owns x/y from then on.
|
|
12686
|
+
if (moves && !dragControls()?.isDragging) {
|
|
12424
12687
|
x.set(snapToOrigin ? mixNumber$1(x0, 0, p) : fx);
|
|
12425
12688
|
y.set(snapToOrigin ? mixNumber$1(y0, 0, p) : fy);
|
|
12426
12689
|
}
|
|
@@ -15639,6 +15902,7 @@
|
|
|
15639
15902
|
exports.getMixer = getMixer;
|
|
15640
15903
|
exports.getOptimisedAppearId = getOptimisedAppearId;
|
|
15641
15904
|
exports.getOriginIndex = getOriginIndex;
|
|
15905
|
+
exports.getSpringOptions = getSpringOptions;
|
|
15642
15906
|
exports.getValueAsType = getValueAsType;
|
|
15643
15907
|
exports.getValueTransition = getValueTransition;
|
|
15644
15908
|
exports.getVariableValue = getVariableValue;
|