motion 12.18.0 → 12.18.2
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/mini.js +7 -1063
- package/dist/es/debug.mjs +1 -0
- package/dist/es/index.mjs +1 -0
- package/dist/es/mini.mjs +1 -0
- package/dist/es/react-client.mjs +2 -0
- package/dist/es/react-m.mjs +2 -0
- package/dist/es/react-mini.mjs +2 -0
- package/dist/es/react.mjs +2 -0
- package/dist/motion.js +1 -1
- package/mini/package.json +1 -1
- package/package.json +11 -11
- package/react/package.json +1 -1
- package/react-client/package.json +1 -1
- package/react-m/package.json +1 -1
- package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +0 -34
- package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +0 -19
- package/dist/es/framer-motion/dist/es/animation/animate/sequence.mjs +0 -14
- package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +0 -11
- package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +0 -52
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +0 -112
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-sequence.mjs +0 -13
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +0 -12
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/get-final-keyframe.mjs +0 -12
- package/dist/es/framer-motion/dist/es/animation/hooks/animation-controls.mjs +0 -80
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animate-style.mjs +0 -17
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animate.mjs +0 -17
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animated-state.mjs +0 -64
- package/dist/es/framer-motion/dist/es/animation/hooks/use-animation.mjs +0 -41
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +0 -102
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +0 -85
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-variant.mjs +0 -65
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element.mjs +0 -26
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/data-id.mjs +0 -6
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/get-appear-id.mjs +0 -7
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/handoff.mjs +0 -38
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +0 -171
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/store-id.mjs +0 -8
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/store.mjs +0 -4
- package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +0 -256
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-repeat-duration.mjs +0 -5
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-time.mjs +0 -23
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/edit.mjs +0 -31
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/normalize-times.mjs +0 -13
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/sort.mjs +0 -14
- package/dist/es/framer-motion/dist/es/animation/utils/create-visual-element.mjs +0 -45
- package/dist/es/framer-motion/dist/es/animation/utils/default-transitions.mjs +0 -40
- package/dist/es/framer-motion/dist/es/animation/utils/is-animation-controls.mjs +0 -7
- package/dist/es/framer-motion/dist/es/animation/utils/is-dom-keyframes.mjs +0 -5
- package/dist/es/framer-motion/dist/es/animation/utils/is-keyframes-target.mjs +0 -5
- package/dist/es/framer-motion/dist/es/animation/utils/is-transition-defined.mjs +0 -10
- package/dist/es/framer-motion/dist/es/animation/utils/stagger.mjs +0 -26
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs +0 -87
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs +0 -64
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +0 -166
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence-data.mjs +0 -9
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs +0 -70
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/utils.mjs +0 -14
- package/dist/es/framer-motion/dist/es/components/AnimateSharedLayout.mjs +0 -15
- package/dist/es/framer-motion/dist/es/components/LayoutGroup/index.mjs +0 -32
- package/dist/es/framer-motion/dist/es/components/LazyMotion/index.mjs +0 -68
- package/dist/es/framer-motion/dist/es/components/MotionConfig/index.mjs +0 -48
- package/dist/es/framer-motion/dist/es/components/Reorder/Group.mjs +0 -53
- package/dist/es/framer-motion/dist/es/components/Reorder/Item.mjs +0 -34
- package/dist/es/framer-motion/dist/es/components/Reorder/namespace.mjs +0 -2
- package/dist/es/framer-motion/dist/es/components/Reorder/utils/check-reorder.mjs +0 -24
- package/dist/es/framer-motion/dist/es/context/DeprecatedLayoutGroupContext.mjs +0 -10
- package/dist/es/framer-motion/dist/es/context/LayoutGroupContext.mjs +0 -6
- package/dist/es/framer-motion/dist/es/context/LazyContext.mjs +0 -6
- package/dist/es/framer-motion/dist/es/context/MotionConfigContext.mjs +0 -13
- package/dist/es/framer-motion/dist/es/context/MotionContext/create.mjs +0 -13
- package/dist/es/framer-motion/dist/es/context/MotionContext/index.mjs +0 -6
- package/dist/es/framer-motion/dist/es/context/MotionContext/utils.mjs +0 -17
- package/dist/es/framer-motion/dist/es/context/PresenceContext.mjs +0 -10
- package/dist/es/framer-motion/dist/es/context/ReorderContext.mjs +0 -6
- package/dist/es/framer-motion/dist/es/context/SwitchLayoutGroupContext.mjs +0 -9
- package/dist/es/framer-motion/dist/es/events/add-dom-event.mjs +0 -6
- package/dist/es/framer-motion/dist/es/events/add-pointer-event.mjs +0 -8
- package/dist/es/framer-motion/dist/es/events/event-info.mjs +0 -15
- package/dist/es/framer-motion/dist/es/events/use-dom-event.mjs +0 -34
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +0 -479
- package/dist/es/framer-motion/dist/es/gestures/drag/index.mjs +0 -27
- package/dist/es/framer-motion/dist/es/gestures/drag/use-drag-controls.mjs +0 -88
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +0 -129
- package/dist/es/framer-motion/dist/es/gestures/focus.mjs +0 -41
- package/dist/es/framer-motion/dist/es/gestures/hover.mjs +0 -30
- package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +0 -156
- package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +0 -50
- package/dist/es/framer-motion/dist/es/gestures/press.mjs +0 -33
- package/dist/es/framer-motion/dist/es/motion/features/Feature.mjs +0 -9
- package/dist/es/framer-motion/dist/es/motion/features/animation/exit.mjs +0 -36
- package/dist/es/framer-motion/dist/es/motion/features/animation/index.mjs +0 -40
- package/dist/es/framer-motion/dist/es/motion/features/animations.mjs +0 -13
- package/dist/es/framer-motion/dist/es/motion/features/definitions.mjs +0 -28
- package/dist/es/framer-motion/dist/es/motion/features/drag.mjs +0 -17
- package/dist/es/framer-motion/dist/es/motion/features/gestures.mjs +0 -21
- package/dist/es/framer-motion/dist/es/motion/features/layout/MeasureLayout.mjs +0 -135
- package/dist/es/framer-motion/dist/es/motion/features/layout.mjs +0 -11
- package/dist/es/framer-motion/dist/es/motion/features/load-features.mjs +0 -12
- package/dist/es/framer-motion/dist/es/motion/features/viewport/index.mjs +0 -72
- package/dist/es/framer-motion/dist/es/motion/features/viewport/observers.mjs +0 -49
- package/dist/es/framer-motion/dist/es/motion/index.mjs +0 -101
- package/dist/es/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +0 -11
- package/dist/es/framer-motion/dist/es/motion/utils/is-motion-component.mjs +0 -12
- package/dist/es/framer-motion/dist/es/motion/utils/symbol.mjs +0 -3
- package/dist/es/framer-motion/dist/es/motion/utils/unwrap-motion-component.mjs +0 -17
- package/dist/es/framer-motion/dist/es/motion/utils/use-motion-ref.mjs +0 -38
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +0 -133
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-state.mjs +0 -79
- package/dist/es/framer-motion/dist/es/motion/utils/valid-prop.mjs +0 -57
- package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +0 -91
- package/dist/es/framer-motion/dist/es/projection/geometry/conversion.mjs +0 -33
- package/dist/es/framer-motion/dist/es/projection/geometry/copy.mjs +0 -31
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-apply.mjs +0 -119
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-calc.mjs +0 -52
- package/dist/es/framer-motion/dist/es/projection/geometry/delta-remove.mjs +0 -54
- package/dist/es/framer-motion/dist/es/projection/geometry/models.mjs +0 -17
- package/dist/es/framer-motion/dist/es/projection/geometry/utils.mjs +0 -31
- package/dist/es/framer-motion/dist/es/projection/node/DocumentProjectionNode.mjs +0 -13
- package/dist/es/framer-motion/dist/es/projection/node/HTMLProjectionNode.mjs +0 -27
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +0 -1605
- package/dist/es/framer-motion/dist/es/projection/node/group.mjs +0 -24
- package/dist/es/framer-motion/dist/es/projection/node/state.mjs +0 -19
- package/dist/es/framer-motion/dist/es/projection/shared/stack.mjs +0 -112
- package/dist/es/framer-motion/dist/es/projection/styles/scale-border-radius.mjs +0 -41
- package/dist/es/framer-motion/dist/es/projection/styles/scale-box-shadow.mjs +0 -35
- package/dist/es/framer-motion/dist/es/projection/styles/scale-correction.mjs +0 -13
- package/dist/es/framer-motion/dist/es/projection/styles/transform.mjs +0 -49
- package/dist/es/framer-motion/dist/es/projection/use-instant-layout-transition.mjs +0 -14
- package/dist/es/framer-motion/dist/es/projection/use-reset-projection.mjs +0 -14
- package/dist/es/framer-motion/dist/es/projection/utils/each-axis.mjs +0 -5
- package/dist/es/framer-motion/dist/es/projection/utils/has-transform.mjs +0 -26
- package/dist/es/framer-motion/dist/es/projection/utils/measure.mjs +0 -17
- package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +0 -478
- package/dist/es/framer-motion/dist/es/render/components/create-factory.mjs +0 -23
- package/dist/es/framer-motion/dist/es/render/components/create-proxy.mjs +0 -38
- package/dist/es/framer-motion/dist/es/render/components/m/create.mjs +0 -6
- package/dist/es/framer-motion/dist/es/render/components/m/elements.mjs +0 -227
- package/dist/es/framer-motion/dist/es/render/components/m/proxy.mjs +0 -6
- package/dist/es/framer-motion/dist/es/render/components/motion/create.mjs +0 -15
- package/dist/es/framer-motion/dist/es/render/components/motion/elements.mjs +0 -194
- package/dist/es/framer-motion/dist/es/render/components/motion/proxy.mjs +0 -6
- package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +0 -43
- package/dist/es/framer-motion/dist/es/render/dom/create-visual-element.mjs +0 -14
- package/dist/es/framer-motion/dist/es/render/dom/features-animation.mjs +0 -14
- package/dist/es/framer-motion/dist/es/render/dom/features-max.mjs +0 -14
- package/dist/es/framer-motion/dist/es/render/dom/features-min.mjs +0 -12
- package/dist/es/framer-motion/dist/es/render/dom/scroll/attach-animation.mjs +0 -17
- package/dist/es/framer-motion/dist/es/render/dom/scroll/attach-function.mjs +0 -23
- package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +0 -14
- package/dist/es/framer-motion/dist/es/render/dom/scroll/info.mjs +0 -56
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/edge.mjs +0 -45
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +0 -60
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/inset.mjs +0 -47
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/offset.mjs +0 -35
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/presets.mjs +0 -20
- package/dist/es/framer-motion/dist/es/render/dom/scroll/on-scroll-handler.mjs +0 -48
- package/dist/es/framer-motion/dist/es/render/dom/scroll/track.mjs +0 -81
- package/dist/es/framer-motion/dist/es/render/dom/scroll/utils/get-timeline.mjs +0 -30
- package/dist/es/framer-motion/dist/es/render/dom/use-render.mjs +0 -33
- package/dist/es/framer-motion/dist/es/render/dom/utils/camel-to-dash.mjs +0 -6
- package/dist/es/framer-motion/dist/es/render/dom/utils/filter-props.mjs +0 -59
- package/dist/es/framer-motion/dist/es/render/dom/utils/is-svg-component.mjs +0 -30
- package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +0 -43
- package/dist/es/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +0 -44
- package/dist/es/framer-motion/dist/es/render/html/config-motion.mjs +0 -12
- package/dist/es/framer-motion/dist/es/render/html/use-props.mjs +0 -57
- package/dist/es/framer-motion/dist/es/render/html/utils/build-styles.mjs +0 -65
- package/dist/es/framer-motion/dist/es/render/html/utils/build-transform.mjs +0 -62
- package/dist/es/framer-motion/dist/es/render/html/utils/create-render-state.mjs +0 -8
- package/dist/es/framer-motion/dist/es/render/html/utils/render.mjs +0 -9
- package/dist/es/framer-motion/dist/es/render/html/utils/scrape-motion-values.mjs +0 -19
- package/dist/es/framer-motion/dist/es/render/object/ObjectVisualElement.mjs +0 -41
- package/dist/es/framer-motion/dist/es/render/store.mjs +0 -3
- package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +0 -45
- package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +0 -12
- package/dist/es/framer-motion/dist/es/render/svg/lowercase-elements.mjs +0 -33
- package/dist/es/framer-motion/dist/es/render/svg/use-props.mjs +0 -24
- package/dist/es/framer-motion/dist/es/render/svg/utils/build-attrs.mjs +0 -57
- package/dist/es/framer-motion/dist/es/render/svg/utils/camel-case-attrs.mjs +0 -30
- package/dist/es/framer-motion/dist/es/render/svg/utils/create-render-state.mjs +0 -8
- package/dist/es/framer-motion/dist/es/render/svg/utils/is-svg-tag.mjs +0 -3
- package/dist/es/framer-motion/dist/es/render/svg/utils/path.mjs +0 -32
- package/dist/es/framer-motion/dist/es/render/svg/utils/render.mjs +0 -12
- package/dist/es/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +0 -19
- package/dist/es/framer-motion/dist/es/render/utils/animation-state.mjs +0 -342
- package/dist/es/framer-motion/dist/es/render/utils/compare-by-depth.mjs +0 -3
- package/dist/es/framer-motion/dist/es/render/utils/flat-tree.mjs +0 -24
- package/dist/es/framer-motion/dist/es/render/utils/get-variant-context.mjs +0 -28
- package/dist/es/framer-motion/dist/es/render/utils/is-controlling-variants.mjs +0 -13
- package/dist/es/framer-motion/dist/es/render/utils/is-variant-label.mjs +0 -8
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +0 -51
- package/dist/es/framer-motion/dist/es/render/utils/resolve-dynamic-variants.mjs +0 -8
- package/dist/es/framer-motion/dist/es/render/utils/resolve-variants.mjs +0 -36
- package/dist/es/framer-motion/dist/es/render/utils/setters.mjs +0 -31
- package/dist/es/framer-motion/dist/es/render/utils/variant-props.mjs +0 -12
- package/dist/es/framer-motion/dist/es/utils/delay.mjs +0 -24
- package/dist/es/framer-motion/dist/es/utils/distance.mjs +0 -9
- package/dist/es/framer-motion/dist/es/utils/get-context-window.mjs +0 -6
- package/dist/es/framer-motion/dist/es/utils/is-browser.mjs +0 -3
- package/dist/es/framer-motion/dist/es/utils/is-ref-object.mjs +0 -7
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/index.mjs +0 -19
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/state.mjs +0 -5
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion-config.mjs +0 -19
- package/dist/es/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.mjs +0 -47
- package/dist/es/framer-motion/dist/es/utils/shallow-compare.mjs +0 -14
- package/dist/es/framer-motion/dist/es/utils/use-animation-frame.mjs +0 -21
- package/dist/es/framer-motion/dist/es/utils/use-constant.mjs +0 -18
- package/dist/es/framer-motion/dist/es/utils/use-cycle.mjs +0 -47
- package/dist/es/framer-motion/dist/es/utils/use-force-update.mjs +0 -19
- package/dist/es/framer-motion/dist/es/utils/use-in-view.mjs +0 -23
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition.mjs +0 -41
- package/dist/es/framer-motion/dist/es/utils/use-is-mounted.mjs +0 -15
- package/dist/es/framer-motion/dist/es/utils/use-isomorphic-effect.mjs +0 -6
- package/dist/es/framer-motion/dist/es/utils/use-motion-value-event.mjs +0 -13
- package/dist/es/framer-motion/dist/es/utils/use-unmount-effect.mjs +0 -7
- package/dist/es/framer-motion/dist/es/value/scroll/use-element-scroll.mjs +0 -14
- package/dist/es/framer-motion/dist/es/value/scroll/use-viewport-scroll.mjs +0 -14
- package/dist/es/framer-motion/dist/es/value/use-combine-values.mjs +0 -37
- package/dist/es/framer-motion/dist/es/value/use-computed.mjs +0 -19
- package/dist/es/framer-motion/dist/es/value/use-inverted-scale.mjs +0 -52
- package/dist/es/framer-motion/dist/es/value/use-motion-template.mjs +0 -45
- package/dist/es/framer-motion/dist/es/value/use-motion-value.mjs +0 -38
- package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +0 -39
- package/dist/es/framer-motion/dist/es/value/use-spring.mjs +0 -22
- package/dist/es/framer-motion/dist/es/value/use-time.mjs +0 -10
- package/dist/es/framer-motion/dist/es/value/use-transform.mjs +0 -29
- package/dist/es/framer-motion/dist/es/value/use-velocity.mjs +0 -35
- package/dist/es/framer-motion/dist/es/value/use-will-change/WillChangeMotionValue.mjs +0 -21
- package/dist/es/framer-motion/dist/es/value/use-will-change/add-will-change.mjs +0 -20
- package/dist/es/framer-motion/dist/es/value/use-will-change/index.mjs +0 -8
- package/dist/es/framer-motion/dist/es/value/use-will-change/is.mjs +0 -7
- package/dist/es/framer-motion/dist/es/value/utils/resolve-motion-value.mjs +0 -12
- package/dist/es/motion/lib/debug.mjs +0 -1
- package/dist/es/motion/lib/index.mjs +0 -131
- package/dist/es/motion/lib/mini.mjs +0 -2
- package/dist/es/motion/lib/react-client.mjs +0 -3
- package/dist/es/motion/lib/react-m.mjs +0 -3
- package/dist/es/motion/lib/react-mini.mjs +0 -2
- package/dist/es/motion/lib/react.mjs +0 -204
- package/dist/es/motion-dom/dist/es/animation/AsyncMotionValueAnimation.mjs +0 -175
- package/dist/es/motion-dom/dist/es/animation/GroupAnimation.mjs +0 -72
- package/dist/es/motion-dom/dist/es/animation/GroupAnimationWithThen.mjs +0 -9
- package/dist/es/motion-dom/dist/es/animation/JSAnimation.mjs +0 -348
- package/dist/es/motion-dom/dist/es/animation/NativeAnimation.mjs +0 -158
- package/dist/es/motion-dom/dist/es/animation/NativeAnimationExtended.mjs +0 -65
- package/dist/es/motion-dom/dist/es/animation/NativeAnimationWrapper.mjs +0 -14
- package/dist/es/motion-dom/dist/es/animation/drivers/frame.mjs +0 -17
- package/dist/es/motion-dom/dist/es/animation/generators/inertia.mjs +0 -87
- package/dist/es/motion-dom/dist/es/animation/generators/keyframes.mjs +0 -51
- package/dist/es/motion-dom/dist/es/animation/generators/spring/defaults.mjs +0 -27
- package/dist/es/motion-dom/dist/es/animation/generators/spring/find.mjs +0 -86
- package/dist/es/motion-dom/dist/es/animation/generators/spring/index.mjs +0 -176
- package/dist/es/motion-dom/dist/es/animation/generators/utils/calc-duration.mjs +0 -17
- package/dist/es/motion-dom/dist/es/animation/generators/utils/create-generator-easing.mjs +0 -19
- package/dist/es/motion-dom/dist/es/animation/generators/utils/is-generator.mjs +0 -5
- package/dist/es/motion-dom/dist/es/animation/generators/utils/velocity.mjs +0 -9
- package/dist/es/motion-dom/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +0 -131
- package/dist/es/motion-dom/dist/es/animation/keyframes/KeyframesResolver.mjs +0 -147
- package/dist/es/motion-dom/dist/es/animation/keyframes/get-final.mjs +0 -11
- package/dist/es/motion-dom/dist/es/animation/keyframes/offsets/default.mjs +0 -9
- package/dist/es/motion-dom/dist/es/animation/keyframes/offsets/fill.mjs +0 -12
- package/dist/es/motion-dom/dist/es/animation/keyframes/offsets/time.mjs +0 -5
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/apply-px-defaults.mjs +0 -11
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/fill-wildcards.mjs +0 -7
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/is-none.mjs +0 -15
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/make-none-animatable.mjs +0 -30
- package/dist/es/motion-dom/dist/es/animation/keyframes/utils/unit-conversion.mjs +0 -36
- package/dist/es/motion-dom/dist/es/animation/utils/WithPromise.mjs +0 -26
- package/dist/es/motion-dom/dist/es/animation/utils/active-animations.mjs +0 -9
- package/dist/es/motion-dom/dist/es/animation/utils/can-animate.mjs +0 -42
- package/dist/es/motion-dom/dist/es/animation/utils/css-variables-conversion.mjs +0 -42
- package/dist/es/motion-dom/dist/es/animation/utils/get-value-transition.mjs +0 -7
- package/dist/es/motion-dom/dist/es/animation/utils/is-animatable.mjs +0 -30
- package/dist/es/motion-dom/dist/es/animation/utils/is-css-variable.mjs +0 -15
- package/dist/es/motion-dom/dist/es/animation/utils/replace-transition-type.mjs +0 -18
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/cubic-bezier.mjs +0 -3
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/is-supported.mjs +0 -14
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/map-easing.mjs +0 -28
- package/dist/es/motion-dom/dist/es/animation/waapi/easing/supported.mjs +0 -15
- package/dist/es/motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs +0 -39
- package/dist/es/motion-dom/dist/es/animation/waapi/supports/partial-keyframes.mjs +0 -13
- package/dist/es/motion-dom/dist/es/animation/waapi/supports/waapi.mjs +0 -37
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/accelerated-values.mjs +0 -14
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/apply-generator.mjs +0 -15
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/linear.mjs +0 -12
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/px-values.mjs +0 -39
- package/dist/es/motion-dom/dist/es/animation/waapi/utils/unsupported-easing.mjs +0 -20
- package/dist/es/motion-dom/dist/es/effects/MotionValueState.mjs +0 -47
- package/dist/es/motion-dom/dist/es/effects/attr/index.mjs +0 -41
- package/dist/es/motion-dom/dist/es/effects/prop/index.mjs +0 -9
- package/dist/es/motion-dom/dist/es/effects/style/index.mjs +0 -52
- package/dist/es/motion-dom/dist/es/effects/style/transform.mjs +0 -38
- package/dist/es/motion-dom/dist/es/effects/svg/index.mjs +0 -41
- package/dist/es/motion-dom/dist/es/effects/utils/create-dom-effect.mjs +0 -18
- package/dist/es/motion-dom/dist/es/effects/utils/create-effect.mjs +0 -21
- package/dist/es/motion-dom/dist/es/frameloop/batcher.mjs +0 -71
- package/dist/es/motion-dom/dist/es/frameloop/frame.mjs +0 -6
- package/dist/es/motion-dom/dist/es/frameloop/index-legacy.mjs +0 -20
- package/dist/es/motion-dom/dist/es/frameloop/microtask.mjs +0 -6
- package/dist/es/motion-dom/dist/es/frameloop/order.mjs +0 -12
- package/dist/es/motion-dom/dist/es/frameloop/render-step.mjs +0 -92
- package/dist/es/motion-dom/dist/es/frameloop/sync-time.mjs +0 -31
- package/dist/es/motion-dom/dist/es/gestures/drag/state/is-active.mjs +0 -9
- package/dist/es/motion-dom/dist/es/gestures/drag/state/set-active.mjs +0 -28
- package/dist/es/motion-dom/dist/es/gestures/hover.mjs +0 -37
- package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +0 -83
- package/dist/es/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.mjs +0 -13
- package/dist/es/motion-dom/dist/es/gestures/press/utils/keyboard.mjs +0 -38
- package/dist/es/motion-dom/dist/es/gestures/press/utils/state.mjs +0 -3
- package/dist/es/motion-dom/dist/es/gestures/utils/is-node-or-child.mjs +0 -20
- package/dist/es/motion-dom/dist/es/gestures/utils/is-primary-pointer.mjs +0 -18
- package/dist/es/motion-dom/dist/es/gestures/utils/setup.mjs +0 -15
- package/dist/es/motion-dom/dist/es/render/dom/is-css-var.mjs +0 -3
- package/dist/es/motion-dom/dist/es/render/dom/parse-transform.mjs +0 -83
- package/dist/es/motion-dom/dist/es/render/dom/style-computed.mjs +0 -10
- package/dist/es/motion-dom/dist/es/render/dom/style-set.mjs +0 -9
- package/dist/es/motion-dom/dist/es/render/dom/utils/camel-to-dash.mjs +0 -5
- package/dist/es/motion-dom/dist/es/render/utils/keys-position.mjs +0 -13
- package/dist/es/motion-dom/dist/es/render/utils/keys-transform.mjs +0 -28
- package/dist/es/motion-dom/dist/es/resize/handle-element.mjs +0 -63
- package/dist/es/motion-dom/dist/es/resize/handle-window.mjs +0 -31
- package/dist/es/motion-dom/dist/es/resize/index.mjs +0 -8
- package/dist/es/motion-dom/dist/es/scroll/observe.mjs +0 -18
- package/dist/es/motion-dom/dist/es/stats/animation-count.mjs +0 -7
- package/dist/es/motion-dom/dist/es/stats/buffer.mjs +0 -6
- package/dist/es/motion-dom/dist/es/stats/index.mjs +0 -117
- package/dist/es/motion-dom/dist/es/utils/interpolate.mjs +0 -79
- package/dist/es/motion-dom/dist/es/utils/is-html-element.mjs +0 -11
- package/dist/es/motion-dom/dist/es/utils/is-svg-element.mjs +0 -11
- package/dist/es/motion-dom/dist/es/utils/is-svg-svg-element.mjs +0 -11
- package/dist/es/motion-dom/dist/es/utils/mix/color.mjs +0 -47
- package/dist/es/motion-dom/dist/es/utils/mix/complex.mjs +0 -93
- package/dist/es/motion-dom/dist/es/utils/mix/immediate.mjs +0 -5
- package/dist/es/motion-dom/dist/es/utils/mix/index.mjs +0 -14
- package/dist/es/motion-dom/dist/es/utils/mix/number.mjs +0 -26
- package/dist/es/motion-dom/dist/es/utils/mix/visibility.mjs +0 -16
- package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +0 -17
- package/dist/es/motion-dom/dist/es/utils/supports/flags.mjs +0 -7
- package/dist/es/motion-dom/dist/es/utils/supports/linear-easing.mjs +0 -15
- package/dist/es/motion-dom/dist/es/utils/supports/memo.mjs +0 -9
- package/dist/es/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +0 -5
- package/dist/es/motion-dom/dist/es/utils/transform.mjs +0 -14
- package/dist/es/motion-dom/dist/es/value/index.mjs +0 -329
- package/dist/es/motion-dom/dist/es/value/map-value.mjs +0 -46
- package/dist/es/motion-dom/dist/es/value/spring-value.mjs +0 -72
- package/dist/es/motion-dom/dist/es/value/subscribe-value.mjs +0 -13
- package/dist/es/motion-dom/dist/es/value/transform-value.mjs +0 -35
- package/dist/es/motion-dom/dist/es/value/types/auto.mjs +0 -9
- package/dist/es/motion-dom/dist/es/value/types/color/hex.mjs +0 -40
- package/dist/es/motion-dom/dist/es/value/types/color/hsla-to-rgba.mjs +0 -42
- package/dist/es/motion-dom/dist/es/value/types/color/hsla.mjs +0 -22
- package/dist/es/motion-dom/dist/es/value/types/color/index.mjs +0 -32
- package/dist/es/motion-dom/dist/es/value/types/color/rgba.mjs +0 -25
- package/dist/es/motion-dom/dist/es/value/types/color/utils.mjs +0 -29
- package/dist/es/motion-dom/dist/es/value/types/complex/filter.mjs +0 -30
- package/dist/es/motion-dom/dist/es/value/types/complex/index.mjs +0 -91
- package/dist/es/motion-dom/dist/es/value/types/dimensions.mjs +0 -15
- package/dist/es/motion-dom/dist/es/value/types/int.mjs +0 -8
- package/dist/es/motion-dom/dist/es/value/types/maps/defaults.mjs +0 -30
- package/dist/es/motion-dom/dist/es/value/types/maps/number.mjs +0 -50
- package/dist/es/motion-dom/dist/es/value/types/maps/transform.mjs +0 -31
- package/dist/es/motion-dom/dist/es/value/types/numbers/index.mjs +0 -17
- package/dist/es/motion-dom/dist/es/value/types/numbers/units.mjs +0 -18
- package/dist/es/motion-dom/dist/es/value/types/test.mjs +0 -6
- package/dist/es/motion-dom/dist/es/value/types/utils/animatable-none.mjs +0 -15
- package/dist/es/motion-dom/dist/es/value/types/utils/color-regex.mjs +0 -3
- package/dist/es/motion-dom/dist/es/value/types/utils/find.mjs +0 -15
- package/dist/es/motion-dom/dist/es/value/types/utils/float-regex.mjs +0 -3
- package/dist/es/motion-dom/dist/es/value/types/utils/get-as-type.mjs +0 -10
- package/dist/es/motion-dom/dist/es/value/types/utils/is-nullish.mjs +0 -5
- package/dist/es/motion-dom/dist/es/value/types/utils/sanitize.mjs +0 -5
- package/dist/es/motion-dom/dist/es/value/types/utils/single-color-regex.mjs +0 -3
- package/dist/es/motion-dom/dist/es/value/utils/is-motion-value.mjs +0 -3
- package/dist/es/motion-dom/dist/es/view/index.mjs +0 -64
- package/dist/es/motion-dom/dist/es/view/queue.mjs +0 -52
- package/dist/es/motion-dom/dist/es/view/start.mjs +0 -155
- package/dist/es/motion-dom/dist/es/view/utils/choose-layer-type.mjs +0 -11
- package/dist/es/motion-dom/dist/es/view/utils/css.mjs +0 -32
- package/dist/es/motion-dom/dist/es/view/utils/get-layer-name.mjs +0 -8
- package/dist/es/motion-dom/dist/es/view/utils/get-view-animations.mjs +0 -12
- package/dist/es/motion-dom/dist/es/view/utils/has-target.mjs +0 -5
- package/dist/es/motion-utils/dist/es/array.mjs +0 -21
- package/dist/es/motion-utils/dist/es/clamp.mjs +0 -9
- package/dist/es/motion-utils/dist/es/easing/anticipate.mjs +0 -5
- package/dist/es/motion-utils/dist/es/easing/back.mjs +0 -9
- package/dist/es/motion-utils/dist/es/easing/circ.mjs +0 -8
- package/dist/es/motion-utils/dist/es/easing/cubic-bezier.mjs +0 -51
- package/dist/es/motion-utils/dist/es/easing/ease.mjs +0 -7
- package/dist/es/motion-utils/dist/es/easing/modifiers/mirror.mjs +0 -5
- package/dist/es/motion-utils/dist/es/easing/modifiers/reverse.mjs +0 -5
- package/dist/es/motion-utils/dist/es/easing/steps.mjs +0 -15
- package/dist/es/motion-utils/dist/es/easing/utils/get-easing-for-segment.mjs +0 -8
- package/dist/es/motion-utils/dist/es/easing/utils/is-bezier-definition.mjs +0 -3
- package/dist/es/motion-utils/dist/es/easing/utils/is-easing-array.mjs +0 -5
- package/dist/es/motion-utils/dist/es/easing/utils/map.mjs +0 -41
- package/dist/es/motion-utils/dist/es/errors.mjs +0 -16
- package/dist/es/motion-utils/dist/es/global-config.mjs +0 -3
- package/dist/es/motion-utils/dist/es/is-numerical-string.mjs +0 -6
- package/dist/es/motion-utils/dist/es/is-object.mjs +0 -5
- package/dist/es/motion-utils/dist/es/is-zero-value-string.mjs +0 -6
- package/dist/es/motion-utils/dist/es/memo.mjs +0 -11
- package/dist/es/motion-utils/dist/es/noop.mjs +0 -4
- package/dist/es/motion-utils/dist/es/pipe.mjs +0 -11
- package/dist/es/motion-utils/dist/es/progress.mjs +0 -19
- package/dist/es/motion-utils/dist/es/subscription-manager.mjs +0 -40
- package/dist/es/motion-utils/dist/es/time-conversion.mjs +0 -12
- package/dist/es/motion-utils/dist/es/velocity-per-second.mjs +0 -11
- package/dist/es/motion-utils/dist/es/warn-once.mjs +0 -14
- package/dist/es/motion-utils/dist/es/wrap.mjs +0 -6
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { setStyle } from '../render/dom/style-set.mjs';
|
|
2
|
-
import { supportsScrollTimeline } from '../utils/supports/scroll-timeline.mjs';
|
|
3
|
-
import { getFinalKeyframe } from './keyframes/get-final.mjs';
|
|
4
|
-
import { WithPromise } from './utils/WithPromise.mjs';
|
|
5
|
-
import { startWaapiAnimation } from './waapi/start-waapi-animation.mjs';
|
|
6
|
-
import { applyGeneratorOptions } from './waapi/utils/apply-generator.mjs';
|
|
7
|
-
import { invariant } from '../../../../motion-utils/dist/es/errors.mjs';
|
|
8
|
-
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
9
|
-
import { noop } from '../../../../motion-utils/dist/es/noop.mjs';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* NativeAnimation implements AnimationPlaybackControls for the browser's Web Animations API.
|
|
13
|
-
*/
|
|
14
|
-
class NativeAnimation extends WithPromise {
|
|
15
|
-
constructor(options) {
|
|
16
|
-
super();
|
|
17
|
-
this.finishedTime = null;
|
|
18
|
-
this.isStopped = false;
|
|
19
|
-
if (!options)
|
|
20
|
-
return;
|
|
21
|
-
const { element, name, keyframes, pseudoElement, allowFlatten = false, finalKeyframe, onComplete, } = options;
|
|
22
|
-
this.isPseudoElement = Boolean(pseudoElement);
|
|
23
|
-
this.allowFlatten = allowFlatten;
|
|
24
|
-
this.options = options;
|
|
25
|
-
invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "motion"?`);
|
|
26
|
-
const transition = applyGeneratorOptions(options);
|
|
27
|
-
this.animation = startWaapiAnimation(element, name, keyframes, transition, pseudoElement);
|
|
28
|
-
if (transition.autoplay === false) {
|
|
29
|
-
this.animation.pause();
|
|
30
|
-
}
|
|
31
|
-
this.animation.onfinish = () => {
|
|
32
|
-
this.finishedTime = this.time;
|
|
33
|
-
if (!pseudoElement) {
|
|
34
|
-
const keyframe = getFinalKeyframe(keyframes, this.options, finalKeyframe, this.speed);
|
|
35
|
-
if (this.updateMotionValue) {
|
|
36
|
-
this.updateMotionValue(keyframe);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
/**
|
|
40
|
-
* If we can, we want to commit the final style as set by the user,
|
|
41
|
-
* rather than the computed keyframe value supplied by the animation.
|
|
42
|
-
*/
|
|
43
|
-
setStyle(element, name, keyframe);
|
|
44
|
-
}
|
|
45
|
-
this.animation.cancel();
|
|
46
|
-
}
|
|
47
|
-
onComplete?.();
|
|
48
|
-
this.notifyFinished();
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
play() {
|
|
52
|
-
if (this.isStopped)
|
|
53
|
-
return;
|
|
54
|
-
this.animation.play();
|
|
55
|
-
if (this.state === "finished") {
|
|
56
|
-
this.updateFinished();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
pause() {
|
|
60
|
-
this.animation.pause();
|
|
61
|
-
}
|
|
62
|
-
complete() {
|
|
63
|
-
this.animation.finish?.();
|
|
64
|
-
}
|
|
65
|
-
cancel() {
|
|
66
|
-
try {
|
|
67
|
-
this.animation.cancel();
|
|
68
|
-
}
|
|
69
|
-
catch (e) { }
|
|
70
|
-
}
|
|
71
|
-
stop() {
|
|
72
|
-
if (this.isStopped)
|
|
73
|
-
return;
|
|
74
|
-
this.isStopped = true;
|
|
75
|
-
const { state } = this;
|
|
76
|
-
if (state === "idle" || state === "finished") {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (this.updateMotionValue) {
|
|
80
|
-
this.updateMotionValue();
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
this.commitStyles();
|
|
84
|
-
}
|
|
85
|
-
if (!this.isPseudoElement)
|
|
86
|
-
this.cancel();
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* WAAPI doesn't natively have any interruption capabilities.
|
|
90
|
-
*
|
|
91
|
-
* In this method, we commit styles back to the DOM before cancelling
|
|
92
|
-
* the animation.
|
|
93
|
-
*
|
|
94
|
-
* This is designed to be overridden by NativeAnimationExtended, which
|
|
95
|
-
* will create a renderless JS animation and sample it twice to calculate
|
|
96
|
-
* its current value, "previous" value, and therefore allow
|
|
97
|
-
* Motion to also correctly calculate velocity for any subsequent animation
|
|
98
|
-
* while deferring the commit until the next animation frame.
|
|
99
|
-
*/
|
|
100
|
-
commitStyles() {
|
|
101
|
-
if (!this.isPseudoElement) {
|
|
102
|
-
this.animation.commitStyles?.();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
get duration() {
|
|
106
|
-
const duration = this.animation.effect?.getComputedTiming?.().duration || 0;
|
|
107
|
-
return millisecondsToSeconds(Number(duration));
|
|
108
|
-
}
|
|
109
|
-
get time() {
|
|
110
|
-
return millisecondsToSeconds(Number(this.animation.currentTime) || 0);
|
|
111
|
-
}
|
|
112
|
-
set time(newTime) {
|
|
113
|
-
this.finishedTime = null;
|
|
114
|
-
this.animation.currentTime = secondsToMilliseconds(newTime);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* The playback speed of the animation.
|
|
118
|
-
* 1 = normal speed, 2 = double speed, 0.5 = half speed.
|
|
119
|
-
*/
|
|
120
|
-
get speed() {
|
|
121
|
-
return this.animation.playbackRate;
|
|
122
|
-
}
|
|
123
|
-
set speed(newSpeed) {
|
|
124
|
-
// Allow backwards playback after finishing
|
|
125
|
-
if (newSpeed < 0)
|
|
126
|
-
this.finishedTime = null;
|
|
127
|
-
this.animation.playbackRate = newSpeed;
|
|
128
|
-
}
|
|
129
|
-
get state() {
|
|
130
|
-
return this.finishedTime !== null
|
|
131
|
-
? "finished"
|
|
132
|
-
: this.animation.playState;
|
|
133
|
-
}
|
|
134
|
-
get startTime() {
|
|
135
|
-
return Number(this.animation.startTime);
|
|
136
|
-
}
|
|
137
|
-
set startTime(newStartTime) {
|
|
138
|
-
this.animation.startTime = newStartTime;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Attaches a timeline to the animation, for instance the `ScrollTimeline`.
|
|
142
|
-
*/
|
|
143
|
-
attachTimeline({ timeline, observe }) {
|
|
144
|
-
if (this.allowFlatten) {
|
|
145
|
-
this.animation.effect?.updateTiming({ easing: "linear" });
|
|
146
|
-
}
|
|
147
|
-
this.animation.onfinish = null;
|
|
148
|
-
if (timeline && supportsScrollTimeline()) {
|
|
149
|
-
this.animation.timeline = timeline;
|
|
150
|
-
return noop;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
return observe(this);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export { NativeAnimation };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { JSAnimation } from './JSAnimation.mjs';
|
|
2
|
-
import { NativeAnimation } from './NativeAnimation.mjs';
|
|
3
|
-
import { replaceTransitionType } from './utils/replace-transition-type.mjs';
|
|
4
|
-
import { replaceStringEasing } from './waapi/utils/unsupported-easing.mjs';
|
|
5
|
-
import { secondsToMilliseconds } from '../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 10ms is chosen here as it strikes a balance between smooth
|
|
9
|
-
* results (more than one keyframe per frame at 60fps) and
|
|
10
|
-
* keyframe quantity.
|
|
11
|
-
*/
|
|
12
|
-
const sampleDelta = 10; //ms
|
|
13
|
-
class NativeAnimationExtended extends NativeAnimation {
|
|
14
|
-
constructor(options) {
|
|
15
|
-
/**
|
|
16
|
-
* The base NativeAnimation function only supports a subset
|
|
17
|
-
* of Motion easings, and WAAPI also only supports some
|
|
18
|
-
* easing functions via string/cubic-bezier definitions.
|
|
19
|
-
*
|
|
20
|
-
* This function replaces those unsupported easing functions
|
|
21
|
-
* with a JS easing function. This will later get compiled
|
|
22
|
-
* to a linear() easing function.
|
|
23
|
-
*/
|
|
24
|
-
replaceStringEasing(options);
|
|
25
|
-
/**
|
|
26
|
-
* Ensure we replace the transition type with a generator function
|
|
27
|
-
* before passing to WAAPI.
|
|
28
|
-
*
|
|
29
|
-
* TODO: Does this have a better home? It could be shared with
|
|
30
|
-
* JSAnimation.
|
|
31
|
-
*/
|
|
32
|
-
replaceTransitionType(options);
|
|
33
|
-
super(options);
|
|
34
|
-
if (options.startTime) {
|
|
35
|
-
this.startTime = options.startTime;
|
|
36
|
-
}
|
|
37
|
-
this.options = options;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* WAAPI doesn't natively have any interruption capabilities.
|
|
41
|
-
*
|
|
42
|
-
* Rather than read commited styles back out of the DOM, we can
|
|
43
|
-
* create a renderless JS animation and sample it twice to calculate
|
|
44
|
-
* its current value, "previous" value, and therefore allow
|
|
45
|
-
* Motion to calculate velocity for any subsequent animation.
|
|
46
|
-
*/
|
|
47
|
-
updateMotionValue(value) {
|
|
48
|
-
const { motionValue, onUpdate, onComplete, element, ...options } = this.options;
|
|
49
|
-
if (!motionValue)
|
|
50
|
-
return;
|
|
51
|
-
if (value !== undefined) {
|
|
52
|
-
motionValue.set(value);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const sampleAnimation = new JSAnimation({
|
|
56
|
-
...options,
|
|
57
|
-
autoplay: false,
|
|
58
|
-
});
|
|
59
|
-
const sampleTime = secondsToMilliseconds(this.finishedTime ?? this.time);
|
|
60
|
-
motionValue.setWithVelocity(sampleAnimation.sample(sampleTime - sampleDelta).value, sampleAnimation.sample(sampleTime).value, sampleDelta);
|
|
61
|
-
sampleAnimation.stop();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export { NativeAnimationExtended };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { NativeAnimation } from './NativeAnimation.mjs';
|
|
2
|
-
|
|
3
|
-
class NativeAnimationWrapper extends NativeAnimation {
|
|
4
|
-
constructor(animation) {
|
|
5
|
-
super();
|
|
6
|
-
this.animation = animation;
|
|
7
|
-
animation.onfinish = () => {
|
|
8
|
-
this.finishedTime = this.time;
|
|
9
|
-
this.notifyFinished();
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { NativeAnimationWrapper };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { time } from '../../frameloop/sync-time.mjs';
|
|
2
|
-
import { frame, cancelFrame, frameData } from '../../frameloop/frame.mjs';
|
|
3
|
-
|
|
4
|
-
const frameloopDriver = (update) => {
|
|
5
|
-
const passTimestamp = ({ timestamp }) => update(timestamp);
|
|
6
|
-
return {
|
|
7
|
-
start: (keepAlive = true) => frame.update(passTimestamp, keepAlive),
|
|
8
|
-
stop: () => cancelFrame(passTimestamp),
|
|
9
|
-
/**
|
|
10
|
-
* If we're processing this frame we can use the
|
|
11
|
-
* framelocked timestamp to keep things in sync.
|
|
12
|
-
*/
|
|
13
|
-
now: () => (frameData.isProcessing ? frameData.timestamp : time.now()),
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { frameloopDriver };
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { spring } from './spring/index.mjs';
|
|
2
|
-
import { calcGeneratorVelocity } from './utils/velocity.mjs';
|
|
3
|
-
|
|
4
|
-
function inertia({ keyframes, velocity = 0.0, power = 0.8, timeConstant = 325, bounceDamping = 10, bounceStiffness = 500, modifyTarget, min, max, restDelta = 0.5, restSpeed, }) {
|
|
5
|
-
const origin = keyframes[0];
|
|
6
|
-
const state = {
|
|
7
|
-
done: false,
|
|
8
|
-
value: origin,
|
|
9
|
-
};
|
|
10
|
-
const isOutOfBounds = (v) => (min !== undefined && v < min) || (max !== undefined && v > max);
|
|
11
|
-
const nearestBoundary = (v) => {
|
|
12
|
-
if (min === undefined)
|
|
13
|
-
return max;
|
|
14
|
-
if (max === undefined)
|
|
15
|
-
return min;
|
|
16
|
-
return Math.abs(min - v) < Math.abs(max - v) ? min : max;
|
|
17
|
-
};
|
|
18
|
-
let amplitude = power * velocity;
|
|
19
|
-
const ideal = origin + amplitude;
|
|
20
|
-
const target = modifyTarget === undefined ? ideal : modifyTarget(ideal);
|
|
21
|
-
/**
|
|
22
|
-
* If the target has changed we need to re-calculate the amplitude, otherwise
|
|
23
|
-
* the animation will start from the wrong position.
|
|
24
|
-
*/
|
|
25
|
-
if (target !== ideal)
|
|
26
|
-
amplitude = target - origin;
|
|
27
|
-
const calcDelta = (t) => -amplitude * Math.exp(-t / timeConstant);
|
|
28
|
-
const calcLatest = (t) => target + calcDelta(t);
|
|
29
|
-
const applyFriction = (t) => {
|
|
30
|
-
const delta = calcDelta(t);
|
|
31
|
-
const latest = calcLatest(t);
|
|
32
|
-
state.done = Math.abs(delta) <= restDelta;
|
|
33
|
-
state.value = state.done ? target : latest;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Ideally this would resolve for t in a stateless way, we could
|
|
37
|
-
* do that by always precalculating the animation but as we know
|
|
38
|
-
* this will be done anyway we can assume that spring will
|
|
39
|
-
* be discovered during that.
|
|
40
|
-
*/
|
|
41
|
-
let timeReachedBoundary;
|
|
42
|
-
let spring$1;
|
|
43
|
-
const checkCatchBoundary = (t) => {
|
|
44
|
-
if (!isOutOfBounds(state.value))
|
|
45
|
-
return;
|
|
46
|
-
timeReachedBoundary = t;
|
|
47
|
-
spring$1 = spring({
|
|
48
|
-
keyframes: [state.value, nearestBoundary(state.value)],
|
|
49
|
-
velocity: calcGeneratorVelocity(calcLatest, t, state.value), // TODO: This should be passing * 1000
|
|
50
|
-
damping: bounceDamping,
|
|
51
|
-
stiffness: bounceStiffness,
|
|
52
|
-
restDelta,
|
|
53
|
-
restSpeed,
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
checkCatchBoundary(0);
|
|
57
|
-
return {
|
|
58
|
-
calculatedDuration: null,
|
|
59
|
-
next: (t) => {
|
|
60
|
-
/**
|
|
61
|
-
* We need to resolve the friction to figure out if we need a
|
|
62
|
-
* spring but we don't want to do this twice per frame. So here
|
|
63
|
-
* we flag if we updated for this frame and later if we did
|
|
64
|
-
* we can skip doing it again.
|
|
65
|
-
*/
|
|
66
|
-
let hasUpdatedFrame = false;
|
|
67
|
-
if (!spring$1 && timeReachedBoundary === undefined) {
|
|
68
|
-
hasUpdatedFrame = true;
|
|
69
|
-
applyFriction(t);
|
|
70
|
-
checkCatchBoundary(t);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* If we have a spring and the provided t is beyond the moment the friction
|
|
74
|
-
* animation crossed the min/max boundary, use the spring.
|
|
75
|
-
*/
|
|
76
|
-
if (timeReachedBoundary !== undefined && t >= timeReachedBoundary) {
|
|
77
|
-
return spring$1.next(t - timeReachedBoundary);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
!hasUpdatedFrame && applyFriction(t);
|
|
81
|
-
return state;
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { inertia };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { interpolate } from '../../utils/interpolate.mjs';
|
|
2
|
-
import { defaultOffset } from '../keyframes/offsets/default.mjs';
|
|
3
|
-
import { convertOffsetToTimes } from '../keyframes/offsets/time.mjs';
|
|
4
|
-
import { easeInOut } from '../../../../../motion-utils/dist/es/easing/ease.mjs';
|
|
5
|
-
import { isEasingArray } from '../../../../../motion-utils/dist/es/easing/utils/is-easing-array.mjs';
|
|
6
|
-
import { easingDefinitionToFunction } from '../../../../../motion-utils/dist/es/easing/utils/map.mjs';
|
|
7
|
-
|
|
8
|
-
function defaultEasing(values, easing) {
|
|
9
|
-
return values.map(() => easing || easeInOut).splice(0, values.length - 1);
|
|
10
|
-
}
|
|
11
|
-
function keyframes({ duration = 300, keyframes: keyframeValues, times, ease = "easeInOut", }) {
|
|
12
|
-
/**
|
|
13
|
-
* Easing functions can be externally defined as strings. Here we convert them
|
|
14
|
-
* into actual functions.
|
|
15
|
-
*/
|
|
16
|
-
const easingFunctions = isEasingArray(ease)
|
|
17
|
-
? ease.map(easingDefinitionToFunction)
|
|
18
|
-
: easingDefinitionToFunction(ease);
|
|
19
|
-
/**
|
|
20
|
-
* This is the Iterator-spec return value. We ensure it's mutable rather than using a generator
|
|
21
|
-
* to reduce GC during animation.
|
|
22
|
-
*/
|
|
23
|
-
const state = {
|
|
24
|
-
done: false,
|
|
25
|
-
value: keyframeValues[0],
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Create a times array based on the provided 0-1 offsets
|
|
29
|
-
*/
|
|
30
|
-
const absoluteTimes = convertOffsetToTimes(
|
|
31
|
-
// Only use the provided offsets if they're the correct length
|
|
32
|
-
// TODO Maybe we should warn here if there's a length mismatch
|
|
33
|
-
times && times.length === keyframeValues.length
|
|
34
|
-
? times
|
|
35
|
-
: defaultOffset(keyframeValues), duration);
|
|
36
|
-
const mapTimeToKeyframe = interpolate(absoluteTimes, keyframeValues, {
|
|
37
|
-
ease: Array.isArray(easingFunctions)
|
|
38
|
-
? easingFunctions
|
|
39
|
-
: defaultEasing(keyframeValues, easingFunctions),
|
|
40
|
-
});
|
|
41
|
-
return {
|
|
42
|
-
calculatedDuration: duration,
|
|
43
|
-
next: (t) => {
|
|
44
|
-
state.value = mapTimeToKeyframe(t);
|
|
45
|
-
state.done = t >= duration;
|
|
46
|
-
return state;
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export { defaultEasing, keyframes };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const springDefaults = {
|
|
2
|
-
// Default spring physics
|
|
3
|
-
stiffness: 100,
|
|
4
|
-
damping: 10,
|
|
5
|
-
mass: 1.0,
|
|
6
|
-
velocity: 0.0,
|
|
7
|
-
// Default duration/bounce-based options
|
|
8
|
-
duration: 800, // in ms
|
|
9
|
-
bounce: 0.3,
|
|
10
|
-
visualDuration: 0.3, // in seconds
|
|
11
|
-
// Rest thresholds
|
|
12
|
-
restSpeed: {
|
|
13
|
-
granular: 0.01,
|
|
14
|
-
default: 2,
|
|
15
|
-
},
|
|
16
|
-
restDelta: {
|
|
17
|
-
granular: 0.005,
|
|
18
|
-
default: 0.5,
|
|
19
|
-
},
|
|
20
|
-
// Limits
|
|
21
|
-
minDuration: 0.01, // in seconds
|
|
22
|
-
maxDuration: 10.0, // in seconds
|
|
23
|
-
minDamping: 0.05,
|
|
24
|
-
maxDamping: 1,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export { springDefaults };
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { springDefaults } from './defaults.mjs';
|
|
2
|
-
import { warning } from '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
3
|
-
import { secondsToMilliseconds, millisecondsToSeconds } from '../../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
4
|
-
import { clamp } from '../../../../../../motion-utils/dist/es/clamp.mjs';
|
|
5
|
-
|
|
6
|
-
const safeMin = 0.001;
|
|
7
|
-
function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass, }) {
|
|
8
|
-
let envelope;
|
|
9
|
-
let derivative;
|
|
10
|
-
warning(duration <= secondsToMilliseconds(springDefaults.maxDuration), "Spring duration must be 10 seconds or less");
|
|
11
|
-
let dampingRatio = 1 - bounce;
|
|
12
|
-
/**
|
|
13
|
-
* Restrict dampingRatio and duration to within acceptable ranges.
|
|
14
|
-
*/
|
|
15
|
-
dampingRatio = clamp(springDefaults.minDamping, springDefaults.maxDamping, dampingRatio);
|
|
16
|
-
duration = clamp(springDefaults.minDuration, springDefaults.maxDuration, millisecondsToSeconds(duration));
|
|
17
|
-
if (dampingRatio < 1) {
|
|
18
|
-
/**
|
|
19
|
-
* Underdamped spring
|
|
20
|
-
*/
|
|
21
|
-
envelope = (undampedFreq) => {
|
|
22
|
-
const exponentialDecay = undampedFreq * dampingRatio;
|
|
23
|
-
const delta = exponentialDecay * duration;
|
|
24
|
-
const a = exponentialDecay - velocity;
|
|
25
|
-
const b = calcAngularFreq(undampedFreq, dampingRatio);
|
|
26
|
-
const c = Math.exp(-delta);
|
|
27
|
-
return safeMin - (a / b) * c;
|
|
28
|
-
};
|
|
29
|
-
derivative = (undampedFreq) => {
|
|
30
|
-
const exponentialDecay = undampedFreq * dampingRatio;
|
|
31
|
-
const delta = exponentialDecay * duration;
|
|
32
|
-
const d = delta * velocity + velocity;
|
|
33
|
-
const e = Math.pow(dampingRatio, 2) * Math.pow(undampedFreq, 2) * duration;
|
|
34
|
-
const f = Math.exp(-delta);
|
|
35
|
-
const g = calcAngularFreq(Math.pow(undampedFreq, 2), dampingRatio);
|
|
36
|
-
const factor = -envelope(undampedFreq) + safeMin > 0 ? -1 : 1;
|
|
37
|
-
return (factor * ((d - e) * f)) / g;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
/**
|
|
42
|
-
* Critically-damped spring
|
|
43
|
-
*/
|
|
44
|
-
envelope = (undampedFreq) => {
|
|
45
|
-
const a = Math.exp(-undampedFreq * duration);
|
|
46
|
-
const b = (undampedFreq - velocity) * duration + 1;
|
|
47
|
-
return -safeMin + a * b;
|
|
48
|
-
};
|
|
49
|
-
derivative = (undampedFreq) => {
|
|
50
|
-
const a = Math.exp(-undampedFreq * duration);
|
|
51
|
-
const b = (velocity - undampedFreq) * (duration * duration);
|
|
52
|
-
return a * b;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
const initialGuess = 5 / duration;
|
|
56
|
-
const undampedFreq = approximateRoot(envelope, derivative, initialGuess);
|
|
57
|
-
duration = secondsToMilliseconds(duration);
|
|
58
|
-
if (isNaN(undampedFreq)) {
|
|
59
|
-
return {
|
|
60
|
-
stiffness: springDefaults.stiffness,
|
|
61
|
-
damping: springDefaults.damping,
|
|
62
|
-
duration,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
const stiffness = Math.pow(undampedFreq, 2) * mass;
|
|
67
|
-
return {
|
|
68
|
-
stiffness,
|
|
69
|
-
damping: dampingRatio * 2 * Math.sqrt(mass * stiffness),
|
|
70
|
-
duration,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
const rootIterations = 12;
|
|
75
|
-
function approximateRoot(envelope, derivative, initialGuess) {
|
|
76
|
-
let result = initialGuess;
|
|
77
|
-
for (let i = 1; i < rootIterations; i++) {
|
|
78
|
-
result = result - envelope(result) / derivative(result);
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
function calcAngularFreq(undampedFreq, dampingRatio) {
|
|
83
|
-
return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export { calcAngularFreq, findSpring };
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { generateLinearEasing } from '../../waapi/utils/linear.mjs';
|
|
2
|
-
import { calcGeneratorDuration, maxGeneratorDuration } from '../utils/calc-duration.mjs';
|
|
3
|
-
import { createGeneratorEasing } from '../utils/create-generator-easing.mjs';
|
|
4
|
-
import { calcGeneratorVelocity } from '../utils/velocity.mjs';
|
|
5
|
-
import { springDefaults } from './defaults.mjs';
|
|
6
|
-
import { findSpring, calcAngularFreq } from './find.mjs';
|
|
7
|
-
import { millisecondsToSeconds, secondsToMilliseconds } from '../../../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
8
|
-
import { clamp } from '../../../../../../motion-utils/dist/es/clamp.mjs';
|
|
9
|
-
|
|
10
|
-
const durationKeys = ["duration", "bounce"];
|
|
11
|
-
const physicsKeys = ["stiffness", "damping", "mass"];
|
|
12
|
-
function isSpringType(options, keys) {
|
|
13
|
-
return keys.some((key) => options[key] !== undefined);
|
|
14
|
-
}
|
|
15
|
-
function getSpringOptions(options) {
|
|
16
|
-
let springOptions = {
|
|
17
|
-
velocity: springDefaults.velocity,
|
|
18
|
-
stiffness: springDefaults.stiffness,
|
|
19
|
-
damping: springDefaults.damping,
|
|
20
|
-
mass: springDefaults.mass,
|
|
21
|
-
isResolvedFromDuration: false,
|
|
22
|
-
...options,
|
|
23
|
-
};
|
|
24
|
-
// stiffness/damping/mass overrides duration/bounce
|
|
25
|
-
if (!isSpringType(options, physicsKeys) &&
|
|
26
|
-
isSpringType(options, durationKeys)) {
|
|
27
|
-
if (options.visualDuration) {
|
|
28
|
-
const visualDuration = options.visualDuration;
|
|
29
|
-
const root = (2 * Math.PI) / (visualDuration * 1.2);
|
|
30
|
-
const stiffness = root * root;
|
|
31
|
-
const damping = 2 *
|
|
32
|
-
clamp(0.05, 1, 1 - (options.bounce || 0)) *
|
|
33
|
-
Math.sqrt(stiffness);
|
|
34
|
-
springOptions = {
|
|
35
|
-
...springOptions,
|
|
36
|
-
mass: springDefaults.mass,
|
|
37
|
-
stiffness,
|
|
38
|
-
damping,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
const derived = findSpring(options);
|
|
43
|
-
springOptions = {
|
|
44
|
-
...springOptions,
|
|
45
|
-
...derived,
|
|
46
|
-
mass: springDefaults.mass,
|
|
47
|
-
};
|
|
48
|
-
springOptions.isResolvedFromDuration = true;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return springOptions;
|
|
52
|
-
}
|
|
53
|
-
function spring(optionsOrVisualDuration = springDefaults.visualDuration, bounce = springDefaults.bounce) {
|
|
54
|
-
const options = typeof optionsOrVisualDuration !== "object"
|
|
55
|
-
? {
|
|
56
|
-
visualDuration: optionsOrVisualDuration,
|
|
57
|
-
keyframes: [0, 1],
|
|
58
|
-
bounce,
|
|
59
|
-
}
|
|
60
|
-
: optionsOrVisualDuration;
|
|
61
|
-
let { restSpeed, restDelta } = options;
|
|
62
|
-
const origin = options.keyframes[0];
|
|
63
|
-
const target = options.keyframes[options.keyframes.length - 1];
|
|
64
|
-
/**
|
|
65
|
-
* This is the Iterator-spec return value. We ensure it's mutable rather than using a generator
|
|
66
|
-
* to reduce GC during animation.
|
|
67
|
-
*/
|
|
68
|
-
const state = { done: false, value: origin };
|
|
69
|
-
const { stiffness, damping, mass, duration, velocity, isResolvedFromDuration, } = getSpringOptions({
|
|
70
|
-
...options,
|
|
71
|
-
velocity: -millisecondsToSeconds(options.velocity || 0),
|
|
72
|
-
});
|
|
73
|
-
const initialVelocity = velocity || 0.0;
|
|
74
|
-
const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass));
|
|
75
|
-
const initialDelta = target - origin;
|
|
76
|
-
const undampedAngularFreq = millisecondsToSeconds(Math.sqrt(stiffness / mass));
|
|
77
|
-
/**
|
|
78
|
-
* If we're working on a granular scale, use smaller defaults for determining
|
|
79
|
-
* when the spring is finished.
|
|
80
|
-
*
|
|
81
|
-
* These defaults have been selected emprically based on what strikes a good
|
|
82
|
-
* ratio between feeling good and finishing as soon as changes are imperceptible.
|
|
83
|
-
*/
|
|
84
|
-
const isGranularScale = Math.abs(initialDelta) < 5;
|
|
85
|
-
restSpeed || (restSpeed = isGranularScale
|
|
86
|
-
? springDefaults.restSpeed.granular
|
|
87
|
-
: springDefaults.restSpeed.default);
|
|
88
|
-
restDelta || (restDelta = isGranularScale
|
|
89
|
-
? springDefaults.restDelta.granular
|
|
90
|
-
: springDefaults.restDelta.default);
|
|
91
|
-
let resolveSpring;
|
|
92
|
-
if (dampingRatio < 1) {
|
|
93
|
-
const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);
|
|
94
|
-
// Underdamped spring
|
|
95
|
-
resolveSpring = (t) => {
|
|
96
|
-
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
97
|
-
return (target -
|
|
98
|
-
envelope *
|
|
99
|
-
(((initialVelocity +
|
|
100
|
-
dampingRatio * undampedAngularFreq * initialDelta) /
|
|
101
|
-
angularFreq) *
|
|
102
|
-
Math.sin(angularFreq * t) +
|
|
103
|
-
initialDelta * Math.cos(angularFreq * t)));
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
else if (dampingRatio === 1) {
|
|
107
|
-
// Critically damped spring
|
|
108
|
-
resolveSpring = (t) => target -
|
|
109
|
-
Math.exp(-undampedAngularFreq * t) *
|
|
110
|
-
(initialDelta +
|
|
111
|
-
(initialVelocity + undampedAngularFreq * initialDelta) * t);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
// Overdamped spring
|
|
115
|
-
const dampedAngularFreq = undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1);
|
|
116
|
-
resolveSpring = (t) => {
|
|
117
|
-
const envelope = Math.exp(-dampingRatio * undampedAngularFreq * t);
|
|
118
|
-
// When performing sinh or cosh values can hit Infinity so we cap them here
|
|
119
|
-
const freqForT = Math.min(dampedAngularFreq * t, 300);
|
|
120
|
-
return (target -
|
|
121
|
-
(envelope *
|
|
122
|
-
((initialVelocity +
|
|
123
|
-
dampingRatio * undampedAngularFreq * initialDelta) *
|
|
124
|
-
Math.sinh(freqForT) +
|
|
125
|
-
dampedAngularFreq *
|
|
126
|
-
initialDelta *
|
|
127
|
-
Math.cosh(freqForT))) /
|
|
128
|
-
dampedAngularFreq);
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
const generator = {
|
|
132
|
-
calculatedDuration: isResolvedFromDuration ? duration || null : null,
|
|
133
|
-
next: (t) => {
|
|
134
|
-
const current = resolveSpring(t);
|
|
135
|
-
if (!isResolvedFromDuration) {
|
|
136
|
-
let currentVelocity = t === 0 ? initialVelocity : 0.0;
|
|
137
|
-
/**
|
|
138
|
-
* We only need to calculate velocity for under-damped springs
|
|
139
|
-
* as over- and critically-damped springs can't overshoot, so
|
|
140
|
-
* checking only for displacement is enough.
|
|
141
|
-
*/
|
|
142
|
-
if (dampingRatio < 1) {
|
|
143
|
-
currentVelocity =
|
|
144
|
-
t === 0
|
|
145
|
-
? secondsToMilliseconds(initialVelocity)
|
|
146
|
-
: calcGeneratorVelocity(resolveSpring, t, current);
|
|
147
|
-
}
|
|
148
|
-
const isBelowVelocityThreshold = Math.abs(currentVelocity) <= restSpeed;
|
|
149
|
-
const isBelowDisplacementThreshold = Math.abs(target - current) <= restDelta;
|
|
150
|
-
state.done =
|
|
151
|
-
isBelowVelocityThreshold && isBelowDisplacementThreshold;
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
state.done = t >= duration;
|
|
155
|
-
}
|
|
156
|
-
state.value = state.done ? target : current;
|
|
157
|
-
return state;
|
|
158
|
-
},
|
|
159
|
-
toString: () => {
|
|
160
|
-
const calculatedDuration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);
|
|
161
|
-
const easing = generateLinearEasing((progress) => generator.next(calculatedDuration * progress).value, calculatedDuration, 30);
|
|
162
|
-
return calculatedDuration + "ms " + easing;
|
|
163
|
-
},
|
|
164
|
-
toTransition: () => { },
|
|
165
|
-
};
|
|
166
|
-
return generator;
|
|
167
|
-
}
|
|
168
|
-
spring.applyToOptions = (options) => {
|
|
169
|
-
const generatorOptions = createGeneratorEasing(options, 100, spring);
|
|
170
|
-
options.ease = generatorOptions.ease;
|
|
171
|
-
options.duration = secondsToMilliseconds(generatorOptions.duration);
|
|
172
|
-
options.type = "keyframes";
|
|
173
|
-
return options;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export { spring };
|