motion 12.0.0-alpha.2 → 12.0.1
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/LICENSE.md +1 -1
- package/README.md +7 -24
- package/dist/cjs/index.js +2792 -2446
- package/dist/cjs/mini.js +629 -193
- package/dist/cjs/react-client.js +3611 -3416
- package/dist/cjs/react-m.js +397 -351
- package/dist/cjs/react-mini.js +225 -191
- package/dist/es/framer-motion/dist/es/animation/animate/index.mjs +3 -2
- package/dist/es/framer-motion/dist/es/animation/animate/resolve-subjects.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animate/single-value.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/animate/subject.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/animators/AcceleratedAnimation.mjs +16 -12
- package/dist/es/framer-motion/dist/es/animation/animators/BaseAnimation.mjs +3 -2
- package/dist/es/framer-motion/dist/es/animation/animators/MainThreadAnimation.mjs +10 -10
- package/dist/es/framer-motion/dist/es/animation/animators/utils/can-animate.mjs +2 -2
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/NativeAnimation.mjs +30 -89
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-elements.mjs +4 -4
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-sequence.mjs +14 -0
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/animate-style.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-partial-keyframes.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/animators/waapi/utils/supports-waapi.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/generators/spring/defaults.mjs +27 -0
- package/dist/es/framer-motion/dist/es/animation/generators/spring/find.mjs +10 -13
- package/dist/es/framer-motion/dist/es/animation/generators/spring/index.mjs +57 -18
- package/dist/es/framer-motion/dist/es/animation/hooks/animation-controls.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/interfaces/motion-value.mjs +7 -6
- package/dist/es/framer-motion/dist/es/animation/interfaces/visual-element-target.mjs +6 -5
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/start.mjs +2 -1
- package/dist/es/framer-motion/dist/es/animation/optimized-appear/store-id.mjs +1 -1
- package/dist/es/framer-motion/dist/es/animation/sequence/create.mjs +32 -6
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/calc-repeat-duration.mjs +5 -0
- package/dist/es/framer-motion/dist/es/animation/sequence/utils/normalize-times.mjs +13 -0
- package/dist/es/framer-motion/dist/es/animation/utils/default-transitions.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/index.mjs +10 -7
- package/dist/es/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs +6 -3
- package/dist/es/framer-motion/dist/es/components/AnimateSharedLayout.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/Reorder/Group.mjs +1 -1
- package/dist/es/framer-motion/dist/es/components/Reorder/Item.mjs +1 -1
- package/dist/es/framer-motion/dist/es/easing/cubic-bezier.mjs +2 -1
- package/dist/es/framer-motion/dist/es/easing/utils/map.mjs +6 -6
- package/dist/es/framer-motion/dist/es/events/event-info.mjs +5 -4
- package/dist/es/framer-motion/dist/es/frameloop/frame.mjs +2 -1
- package/dist/es/framer-motion/dist/es/frameloop/render-step.mjs +3 -2
- package/dist/es/framer-motion/dist/es/gestures/drag/VisualElementDragControls.mjs +12 -15
- package/dist/es/framer-motion/dist/es/gestures/drag/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/constraints.mjs +2 -1
- package/dist/es/framer-motion/dist/es/gestures/hover.mjs +20 -22
- package/dist/es/framer-motion/dist/es/gestures/pan/PanSession.mjs +6 -5
- package/dist/es/framer-motion/dist/es/gestures/pan/index.mjs +2 -1
- package/dist/es/framer-motion/dist/es/gestures/press.mjs +20 -119
- package/dist/es/framer-motion/dist/es/motion/index.mjs +11 -7
- package/dist/es/framer-motion/dist/es/motion/utils/is-forced-motion-value.mjs +1 -1
- package/dist/es/framer-motion/dist/es/motion/utils/use-motion-ref.mjs +3 -1
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-element.mjs +1 -1
- package/dist/es/framer-motion/dist/es/motion/utils/use-visual-state.mjs +11 -5
- package/dist/es/framer-motion/dist/es/projection/animation/mix-values.mjs +3 -2
- package/dist/es/framer-motion/dist/es/projection/node/create-projection-node.mjs +29 -23
- package/dist/es/framer-motion/dist/es/render/VisualElement.mjs +15 -13
- package/dist/es/framer-motion/dist/es/render/dom/DOMKeyframesResolver.mjs +4 -3
- package/dist/es/framer-motion/dist/es/render/dom/DOMVisualElement.mjs +15 -0
- package/dist/es/framer-motion/dist/es/render/dom/resize/handle-element.mjs +2 -1
- package/dist/es/framer-motion/dist/es/render/dom/scroll/index.mjs +4 -4
- package/dist/es/framer-motion/dist/es/render/dom/scroll/info.mjs +2 -1
- package/dist/es/framer-motion/dist/es/render/dom/scroll/offsets/index.mjs +6 -5
- package/dist/es/framer-motion/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/dom/utils/unit-conversion.mjs +2 -14
- package/dist/es/framer-motion/dist/es/render/dom/viewport/index.mjs +4 -3
- package/dist/es/framer-motion/dist/es/render/html/HTMLVisualElement.mjs +6 -20
- package/dist/es/framer-motion/dist/es/render/html/utils/build-styles.mjs +2 -2
- package/dist/es/framer-motion/dist/es/render/html/utils/build-transform.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/html/utils/keys-position.mjs +13 -0
- package/dist/es/framer-motion/dist/es/render/svg/SVGVisualElement.mjs +6 -6
- package/dist/es/framer-motion/dist/es/render/svg/config-motion.mjs +57 -24
- package/dist/es/framer-motion/dist/es/render/svg/utils/build-attrs.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/svg/utils/scrape-motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/delay.mjs +2 -1
- package/dist/es/framer-motion/dist/es/utils/get-context-window.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/interpolate.mjs +8 -5
- package/dist/es/framer-motion/dist/es/utils/mix/color.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/mix/complex.mjs +1 -1
- package/dist/es/framer-motion/dist/es/utils/offsets/fill.mjs +2 -1
- package/dist/es/framer-motion/dist/es/utils/use-instant-transition.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/index.mjs +2 -2
- package/dist/es/framer-motion/dist/es/value/use-inverted-scale.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/use-scroll.mjs +1 -1
- package/dist/es/framer-motion/dist/es/value/use-spring.mjs +3 -3
- package/dist/es/framer-motion/dist/es/value/use-will-change/get-will-change-name.mjs +1 -1
- package/dist/es/motion/lib/index.mjs +12 -7
- package/dist/es/motion/lib/mini.mjs +1 -0
- package/dist/es/motion/lib/react.mjs +41 -37
- package/dist/es/{framer-motion/dist/es/animation/GroupPlaybackControls.mjs → motion-dom/dist/es/animation/controls/BaseGroup.mjs} +7 -6
- package/dist/es/motion-dom/dist/es/animation/controls/Group.mjs +13 -0
- package/dist/es/{framer-motion/dist/es/easing → motion-dom/dist/es/animation/generators}/utils/create-generator-easing.mjs +6 -3
- package/dist/es/motion-dom/dist/es/animation/waapi/NativeAnimationControls.mjs +85 -0
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi → motion-dom/dist/es/animation/waapi/utils}/easing.mjs +3 -3
- package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/waapi/utils/linear.mjs +4 -4
- package/dist/es/motion-dom/dist/es/gestures/drag/state/is-active.mjs +9 -0
- package/dist/es/motion-dom/dist/es/gestures/drag/state/set-active.mjs +28 -0
- package/dist/es/motion-dom/dist/es/gestures/hover.mjs +37 -0
- package/dist/es/motion-dom/dist/es/gestures/press/index.mjs +76 -0
- package/dist/es/motion-dom/dist/es/gestures/press/utils/is-keyboard-accessible.mjs +13 -0
- package/dist/es/motion-dom/dist/es/gestures/press/utils/keyboard.mjs +38 -0
- package/dist/es/motion-dom/dist/es/gestures/press/utils/state.mjs +3 -0
- package/dist/es/motion-dom/dist/es/gestures/utils/setup.mjs +15 -0
- package/dist/es/motion-dom/dist/es/utils/resolve-elements.mjs +22 -0
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-linear-easing.mjs → motion-dom/dist/es/utils/supports/linear-easing.mjs} +1 -1
- package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/memo-supports.mjs → motion-dom/dist/es/utils/supports/memo.mjs} +3 -2
- package/dist/es/motion-dom/dist/es/utils/supports/scroll-timeline.mjs +6 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/memo.mjs +1 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/noop.mjs +1 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/progress.mjs +1 -0
- package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/time-conversion.mjs +2 -0
- package/dist/motion.dev.js +2792 -2446
- package/dist/motion.js +1 -1
- package/package.json +6 -6
- package/.turbo/turbo-build.log +0 -47
- package/dist/es/framer-motion/dist/es/gestures/drag/utils/lock.mjs +0 -53
- package/dist/es/framer-motion/dist/es/render/dom/scroll/supports.mjs +0 -5
- package/dist/es/framer-motion/dist/es/render/dom/utils/resolve-element.mjs +0 -28
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/mini.js +0 -2
- package/lib/mini.js.map +0 -1
- package/lib/react-client.js +0 -3
- package/lib/react-client.js.map +0 -1
- package/lib/react-m.js +0 -3
- package/lib/react-m.js.map +0 -1
- package/lib/react-mini.js +0 -3
- package/lib/react-mini.js.map +0 -1
- package/lib/react.js +0 -3
- package/lib/react.js.map +0 -1
- package/rollup.config.mjs +0 -210
- package/src/index.ts +0 -1
- package/src/mini.ts +0 -1
- package/src/react-client.ts +0 -3
- package/src/react-m.ts +0 -3
- package/src/react-mini.ts +0 -3
- package/src/react.ts +0 -3
- package/tsconfig.json +0 -25
- package/types/index.d.ts +0 -1
- package/types/mini.d.ts +0 -1
- package/types/react-client.d.ts +0 -1
- package/types/react-m.d.ts +0 -1
- package/types/react-mini.d.ts +0 -1
- package/types/react.d.ts +0 -1
- /package/dist/es/framer-motion/dist/es/render/html/utils/{transform.mjs → keys-transform.mjs} +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/calc-duration.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/generators/utils/is-generator.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/animation/utils/get-value-transition.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/animation/animators → motion-dom/dist/es/animation}/waapi/utils/attach-timeline.mjs +0 -0
- /package/dist/es/{framer-motion → motion-dom}/dist/es/gestures/utils/is-node-or-child.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/events → motion-dom/dist/es/gestures}/utils/is-primary-pointer.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/easing → motion-dom/dist/es}/utils/is-bezier-definition.mjs +0 -0
- /package/dist/es/{framer-motion/dist/es/animation/animators/waapi/utils/supports-flags.mjs → motion-dom/dist/es/utils/supports/flags.mjs} +0 -0
- /package/dist/es/{framer-motion/dist/es/utils → motion-utils/dist/es}/errors.mjs +0 -0
|
@@ -1,30 +1,31 @@
|
|
|
1
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { noop } from '../../../../../motion-utils/dist/es/noop.mjs';
|
|
3
|
+
import { getValueTransition } from '../../../../../motion-dom/dist/es/animation/utils/get-value-transition.mjs';
|
|
4
|
+
import { animateSingleValue } from '../../animation/animate/single-value.mjs';
|
|
5
|
+
import { getOptimisedAppearId } from '../../animation/optimized-appear/get-appear-id.mjs';
|
|
6
|
+
import { cancelFrame, frameData, frameSteps, frame } from '../../frameloop/frame.mjs';
|
|
7
|
+
import { microtask } from '../../frameloop/microtask.mjs';
|
|
8
|
+
import { time } from '../../frameloop/sync-time.mjs';
|
|
9
|
+
import { isSVGElement } from '../../render/dom/utils/is-svg-element.mjs';
|
|
10
|
+
import { FlatTree } from '../../render/utils/flat-tree.mjs';
|
|
11
|
+
import { clamp } from '../../utils/clamp.mjs';
|
|
12
|
+
import { delay } from '../../utils/delay.mjs';
|
|
13
|
+
import { mixNumber } from '../../utils/mix/number.mjs';
|
|
1
14
|
import { SubscriptionManager } from '../../utils/subscription-manager.mjs';
|
|
15
|
+
import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
|
|
2
16
|
import { mixValues } from '../animation/mix-values.mjs';
|
|
3
17
|
import { copyBoxInto, copyAxisDeltaInto } from '../geometry/copy.mjs';
|
|
4
18
|
import { translateAxis, transformBox, applyBoxDelta, applyTreeDeltas } from '../geometry/delta-apply.mjs';
|
|
5
19
|
import { calcRelativePosition, calcRelativeBox, calcBoxDelta, calcLength, isNear } from '../geometry/delta-calc.mjs';
|
|
6
20
|
import { removeBoxTransforms } from '../geometry/delta-remove.mjs';
|
|
7
|
-
import {
|
|
21
|
+
import { createBox, createDelta } from '../geometry/models.mjs';
|
|
8
22
|
import { boxEqualsRounded, isDeltaZero, axisDeltaEquals, aspectRatio, boxEquals } from '../geometry/utils.mjs';
|
|
9
23
|
import { NodeStack } from '../shared/stack.mjs';
|
|
10
24
|
import { scaleCorrectors } from '../styles/scale-correction.mjs';
|
|
11
25
|
import { buildProjectionTransform } from '../styles/transform.mjs';
|
|
12
26
|
import { eachAxis } from '../utils/each-axis.mjs';
|
|
13
27
|
import { hasTransform, hasScale, has2DTranslate } from '../utils/has-transform.mjs';
|
|
14
|
-
import { FlatTree } from '../../render/utils/flat-tree.mjs';
|
|
15
|
-
import { resolveMotionValue } from '../../value/utils/resolve-motion-value.mjs';
|
|
16
28
|
import { globalProjectionState } from './state.mjs';
|
|
17
|
-
import { delay } from '../../utils/delay.mjs';
|
|
18
|
-
import { mixNumber } from '../../utils/mix/number.mjs';
|
|
19
|
-
import { isSVGElement } from '../../render/dom/utils/is-svg-element.mjs';
|
|
20
|
-
import { animateSingleValue } from '../../animation/animate/single-value.mjs';
|
|
21
|
-
import { clamp } from '../../utils/clamp.mjs';
|
|
22
|
-
import { cancelFrame, frameData, frameSteps, frame } from '../../frameloop/frame.mjs';
|
|
23
|
-
import { noop } from '../../utils/noop.mjs';
|
|
24
|
-
import { time } from '../../frameloop/sync-time.mjs';
|
|
25
|
-
import { microtask } from '../../frameloop/microtask.mjs';
|
|
26
|
-
import { getOptimisedAppearId } from '../../animation/optimized-appear/get-appear-id.mjs';
|
|
27
|
-
import { createBox, createDelta } from '../geometry/models.mjs';
|
|
28
29
|
|
|
29
30
|
const metrics = {
|
|
30
31
|
type: "projectionFrame",
|
|
@@ -273,7 +274,7 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
273
274
|
if (this.options.animate !== false &&
|
|
274
275
|
visualElement &&
|
|
275
276
|
(layoutId || layout)) {
|
|
276
|
-
this.addEventListener("didUpdate", ({ delta, hasLayoutChanged,
|
|
277
|
+
this.addEventListener("didUpdate", ({ delta, hasLayoutChanged, hasRelativeLayoutChanged, layout: newLayout, }) => {
|
|
277
278
|
if (this.isTreeAnimationBlocked()) {
|
|
278
279
|
this.target = undefined;
|
|
279
280
|
this.relativeTarget = undefined;
|
|
@@ -288,20 +289,25 @@ function createProjectionNode({ attachResizeListener, defaultParent, measureScro
|
|
|
288
289
|
* The target layout of the element might stay the same,
|
|
289
290
|
* but its position relative to its parent has changed.
|
|
290
291
|
*/
|
|
291
|
-
const
|
|
292
|
-
!boxEqualsRounded(this.targetLayout, newLayout)
|
|
293
|
-
|
|
292
|
+
const hasTargetChanged = !this.targetLayout ||
|
|
293
|
+
!boxEqualsRounded(this.targetLayout, newLayout);
|
|
294
|
+
/*
|
|
295
|
+
* Note: Disabled to fix relative animations always triggering new
|
|
296
|
+
* layout animations. If this causes further issues, we can try
|
|
297
|
+
* a different approach to detecting relative target changes.
|
|
298
|
+
*/
|
|
299
|
+
// || hasRelativeLayoutChanged
|
|
294
300
|
/**
|
|
295
301
|
* If the layout hasn't seemed to have changed, it might be that the
|
|
296
302
|
* element is visually in the same place in the document but its position
|
|
297
303
|
* relative to its parent has indeed changed. So here we check for that.
|
|
298
304
|
*/
|
|
299
|
-
const hasOnlyRelativeTargetChanged = !hasLayoutChanged &&
|
|
305
|
+
const hasOnlyRelativeTargetChanged = !hasLayoutChanged && hasRelativeLayoutChanged;
|
|
300
306
|
if (this.options.layoutRoot ||
|
|
301
307
|
(this.resumeFrom && this.resumeFrom.instance) ||
|
|
302
308
|
hasOnlyRelativeTargetChanged ||
|
|
303
309
|
(hasLayoutChanged &&
|
|
304
|
-
(
|
|
310
|
+
(hasTargetChanged || !this.currentAnimation))) {
|
|
305
311
|
if (this.resumeFrom) {
|
|
306
312
|
this.resumingFrom = this.resumeFrom;
|
|
307
313
|
this.resumingFrom.resumingFrom = undefined;
|
|
@@ -1417,7 +1423,7 @@ function notifyLayoutUpdate(node) {
|
|
|
1417
1423
|
calcBoxDelta(visualDelta, layout, snapshot.layoutBox);
|
|
1418
1424
|
}
|
|
1419
1425
|
const hasLayoutChanged = !isDeltaZero(layoutDelta);
|
|
1420
|
-
let
|
|
1426
|
+
let hasRelativeLayoutChanged = false;
|
|
1421
1427
|
if (!node.resumeFrom) {
|
|
1422
1428
|
const relativeParent = node.getClosestProjectingParent();
|
|
1423
1429
|
/**
|
|
@@ -1432,7 +1438,7 @@ function notifyLayoutUpdate(node) {
|
|
|
1432
1438
|
const relativeLayout = createBox();
|
|
1433
1439
|
calcRelativePosition(relativeLayout, layout, parentLayout.layoutBox);
|
|
1434
1440
|
if (!boxEqualsRounded(relativeSnapshot, relativeLayout)) {
|
|
1435
|
-
|
|
1441
|
+
hasRelativeLayoutChanged = true;
|
|
1436
1442
|
}
|
|
1437
1443
|
if (relativeParent.options.layoutRoot) {
|
|
1438
1444
|
node.relativeTarget = relativeLayout;
|
|
@@ -1448,7 +1454,7 @@ function notifyLayoutUpdate(node) {
|
|
|
1448
1454
|
delta: visualDelta,
|
|
1449
1455
|
layoutDelta,
|
|
1450
1456
|
hasLayoutChanged,
|
|
1451
|
-
|
|
1457
|
+
hasRelativeLayoutChanged,
|
|
1452
1458
|
});
|
|
1453
1459
|
}
|
|
1454
1460
|
else if (node.isLead()) {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
+
import { time } from '../frameloop/sync-time.mjs';
|
|
2
|
+
import { featureDefinitions } from '../motion/features/definitions.mjs';
|
|
3
|
+
import { createBox } from '../projection/geometry/models.mjs';
|
|
4
|
+
import { isNumericalString } from '../utils/is-numerical-string.mjs';
|
|
5
|
+
import { isZeroValueString } from '../utils/is-zero-value-string.mjs';
|
|
1
6
|
import { initPrefersReducedMotion } from '../utils/reduced-motion/index.mjs';
|
|
2
7
|
import { hasReducedMotionListener, prefersReducedMotion } from '../utils/reduced-motion/state.mjs';
|
|
3
8
|
import { SubscriptionManager } from '../utils/subscription-manager.mjs';
|
|
9
|
+
import { warnOnce } from '../utils/warn-once.mjs';
|
|
4
10
|
import { motionValue } from '../value/index.mjs';
|
|
11
|
+
import { complex } from '../value/types/complex/index.mjs';
|
|
5
12
|
import { isMotionValue } from '../value/utils/is-motion-value.mjs';
|
|
6
|
-
import {
|
|
13
|
+
import { getAnimatableNone } from './dom/value-types/animatable-none.mjs';
|
|
14
|
+
import { findValueType } from './dom/value-types/find.mjs';
|
|
15
|
+
import { transformProps } from './html/utils/keys-transform.mjs';
|
|
16
|
+
import { visualElementStore } from './store.mjs';
|
|
7
17
|
import { isControllingVariants, isVariantNode } from './utils/is-controlling-variants.mjs';
|
|
18
|
+
import { KeyframeResolver } from './utils/KeyframesResolver.mjs';
|
|
8
19
|
import { updateMotionValuesFromProps } from './utils/motion-values.mjs';
|
|
9
20
|
import { resolveVariantFromProps } from './utils/resolve-variants.mjs';
|
|
10
|
-
import { warnOnce } from '../utils/warn-once.mjs';
|
|
11
|
-
import { featureDefinitions } from '../motion/features/definitions.mjs';
|
|
12
|
-
import { visualElementStore } from './store.mjs';
|
|
13
|
-
import { KeyframeResolver } from './utils/KeyframesResolver.mjs';
|
|
14
|
-
import { isNumericalString } from '../utils/is-numerical-string.mjs';
|
|
15
|
-
import { isZeroValueString } from '../utils/is-zero-value-string.mjs';
|
|
16
|
-
import { findValueType } from './dom/value-types/find.mjs';
|
|
17
|
-
import { complex } from '../value/types/complex/index.mjs';
|
|
18
|
-
import { getAnimatableNone } from './dom/value-types/animatable-none.mjs';
|
|
19
|
-
import { createBox } from '../projection/geometry/models.mjs';
|
|
20
|
-
import { time } from '../frameloop/sync-time.mjs';
|
|
21
21
|
import { frame, cancelFrame } from '../frameloop/frame.mjs';
|
|
22
22
|
|
|
23
23
|
const propEventHandlers = [
|
|
@@ -114,7 +114,8 @@ class VisualElement {
|
|
|
114
114
|
frame.render(this.render, false, true);
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
|
-
const { latestValues, renderState } = visualState;
|
|
117
|
+
const { latestValues, renderState, onUpdate } = visualState;
|
|
118
|
+
this.onUpdate = onUpdate;
|
|
118
119
|
this.latestValues = latestValues;
|
|
119
120
|
this.baseTarget = { ...latestValues };
|
|
120
121
|
this.initialValues = props.initial ? { ...latestValues } : {};
|
|
@@ -314,6 +315,7 @@ class VisualElement {
|
|
|
314
315
|
if (this.handleChildMotionValue) {
|
|
315
316
|
this.handleChildMotionValue();
|
|
316
317
|
}
|
|
318
|
+
this.onUpdate && this.onUpdate(this);
|
|
317
319
|
}
|
|
318
320
|
getProps() {
|
|
319
321
|
return this.props;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { isNone } from '../../animation/utils/is-none.mjs';
|
|
2
|
+
import { positionalKeys } from '../html/utils/keys-position.mjs';
|
|
3
|
+
import { makeNoneKeyframesAnimatable } from '../html/utils/make-none-animatable.mjs';
|
|
4
|
+
import { KeyframeResolver } from '../utils/KeyframesResolver.mjs';
|
|
2
5
|
import { getVariableValue } from './utils/css-variables-conversion.mjs';
|
|
3
6
|
import { isCSSVariableToken } from './utils/is-css-variable.mjs';
|
|
4
|
-
import {
|
|
7
|
+
import { isNumOrPxType, positionalValues } from './utils/unit-conversion.mjs';
|
|
5
8
|
import { findDimensionValueType } from './value-types/dimensions.mjs';
|
|
6
|
-
import { KeyframeResolver } from '../utils/KeyframesResolver.mjs';
|
|
7
|
-
import { makeNoneKeyframesAnimatable } from '../html/utils/make-none-animatable.mjs';
|
|
8
9
|
|
|
9
10
|
class DOMKeyframesResolver extends KeyframeResolver {
|
|
10
11
|
constructor(unresolvedKeyframes, onComplete, name, motionValue, element) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { VisualElement } from '../VisualElement.mjs';
|
|
2
2
|
import { DOMKeyframesResolver } from './DOMKeyframesResolver.mjs';
|
|
3
|
+
import { isMotionValue } from '../../value/utils/is-motion-value.mjs';
|
|
3
4
|
|
|
4
5
|
class DOMVisualElement extends VisualElement {
|
|
5
6
|
constructor() {
|
|
@@ -23,6 +24,20 @@ class DOMVisualElement extends VisualElement {
|
|
|
23
24
|
delete vars[key];
|
|
24
25
|
delete style[key];
|
|
25
26
|
}
|
|
27
|
+
handleChildMotionValue() {
|
|
28
|
+
if (this.childSubscription) {
|
|
29
|
+
this.childSubscription();
|
|
30
|
+
delete this.childSubscription;
|
|
31
|
+
}
|
|
32
|
+
const { children } = this.props;
|
|
33
|
+
if (isMotionValue(children)) {
|
|
34
|
+
this.childSubscription = children.on("change", (latest) => {
|
|
35
|
+
if (this.current) {
|
|
36
|
+
this.current.textContent = `${latest}`;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
26
41
|
}
|
|
27
42
|
|
|
28
43
|
export { DOMVisualElement };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { resolveElements } from '../../../../../../motion-dom/dist/es/utils/resolve-elements.mjs';
|
|
2
3
|
|
|
3
4
|
const resizeHandlers = new WeakMap();
|
|
4
5
|
let observer;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { supportsScrollTimeline } from '../../../../../../motion-dom/dist/es/utils/supports/scroll-timeline.mjs';
|
|
2
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
3
|
+
import { noop } from '../../../../../../motion-utils/dist/es/noop.mjs';
|
|
2
4
|
import { observeTimeline } from './observe.mjs';
|
|
3
|
-
import {
|
|
4
|
-
import { noop } from '../../../utils/noop.mjs';
|
|
5
|
+
import { scrollInfo } from './track.mjs';
|
|
5
6
|
|
|
6
7
|
function scrollTimelineFallback({ source, container, axis = "y", }) {
|
|
7
8
|
// Support legacy source argument. Deprecate later.
|
|
@@ -46,7 +47,6 @@ function needsElementTracking(options) {
|
|
|
46
47
|
}
|
|
47
48
|
function scrollFunction(onScroll, options) {
|
|
48
49
|
if (isOnScrollWithInfo(onScroll) || needsElementTracking(options)) {
|
|
49
|
-
console.log(isOnScrollWithInfo(onScroll), needsElementTracking(options));
|
|
50
50
|
return scrollInfo((info) => {
|
|
51
51
|
onScroll(info[options.axis].progress, info);
|
|
52
52
|
}, options);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { progress } from '../../../../../../motion-utils/dist/es/progress.mjs';
|
|
2
3
|
import { velocityPerSecond } from '../../../utils/velocity-per-second.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ScrollOffset } from './presets.mjs';
|
|
3
|
-
import { resolveOffset } from './offset.mjs';
|
|
1
|
+
import { clamp } from '../../../../utils/clamp.mjs';
|
|
4
2
|
import { interpolate } from '../../../../utils/interpolate.mjs';
|
|
5
3
|
import { defaultOffset } from '../../../../utils/offsets/default.mjs';
|
|
4
|
+
import { calcInset } from './inset.mjs';
|
|
5
|
+
import { resolveOffset } from './offset.mjs';
|
|
6
|
+
import { ScrollOffset } from './presets.mjs';
|
|
6
7
|
|
|
7
8
|
const point = { x: 0, y: 0 };
|
|
8
9
|
function getTargetSize(target) {
|
|
@@ -50,10 +51,10 @@ function resolveOffsets(container, info, options) {
|
|
|
50
51
|
* to map scroll value into a progress.
|
|
51
52
|
*/
|
|
52
53
|
if (hasChanged) {
|
|
53
|
-
info[axis].interpolate = interpolate(info[axis].offset, defaultOffset(offsetDefinition));
|
|
54
|
+
info[axis].interpolate = interpolate(info[axis].offset, defaultOffset(offsetDefinition), { clamp: false });
|
|
54
55
|
info[axis].interpolatorOffsets = [...info[axis].offset];
|
|
55
56
|
}
|
|
56
|
-
info[axis].progress = info[axis].interpolate(info[axis].current);
|
|
57
|
+
info[axis].progress = clamp(0, 1, info[axis].interpolate(info[axis].current));
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
export { resolveOffsets };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { invariant } from '
|
|
1
|
+
import { invariant } from '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
2
|
import { isNumericalString } from '../../../utils/is-numerical-string.mjs';
|
|
3
3
|
import { isCSSVariableToken } from './is-css-variable.mjs';
|
|
4
4
|
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { transformPropOrder } from '../../html/utils/transform.mjs';
|
|
2
1
|
import { number } from '../../../value/types/numbers/index.mjs';
|
|
3
2
|
import { px } from '../../../value/types/numbers/units.mjs';
|
|
3
|
+
import { transformPropOrder } from '../../html/utils/keys-transform.mjs';
|
|
4
4
|
|
|
5
|
-
const positionalKeys = new Set([
|
|
6
|
-
"width",
|
|
7
|
-
"height",
|
|
8
|
-
"top",
|
|
9
|
-
"left",
|
|
10
|
-
"right",
|
|
11
|
-
"bottom",
|
|
12
|
-
"x",
|
|
13
|
-
"y",
|
|
14
|
-
"translateX",
|
|
15
|
-
"translateY",
|
|
16
|
-
]);
|
|
17
5
|
const isNumOrPxType = (v) => v === number || v === px;
|
|
18
6
|
const getPosFromMatrix = (matrix, pos) => parseFloat(matrix.split(", ")[pos]);
|
|
19
7
|
const getTranslateFromMatrix = (pos2, pos3) => (_bbox, { transform }) => {
|
|
@@ -62,4 +50,4 @@ const positionalValues = {
|
|
|
62
50
|
positionalValues.translateX = positionalValues.x;
|
|
63
51
|
positionalValues.translateY = positionalValues.y;
|
|
64
52
|
|
|
65
|
-
export { isNumOrPxType,
|
|
53
|
+
export { isNumOrPxType, positionalValues, removeNonTranslationalTransform };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { resolveElements } from '../../../../../../motion-dom/dist/es/utils/resolve-elements.mjs';
|
|
2
3
|
|
|
3
4
|
const thresholds = {
|
|
4
5
|
some: 0,
|
|
@@ -17,7 +18,7 @@ function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount =
|
|
|
17
18
|
if (entry.isIntersecting === Boolean(onEnd))
|
|
18
19
|
return;
|
|
19
20
|
if (entry.isIntersecting) {
|
|
20
|
-
const newOnEnd = onStart(entry);
|
|
21
|
+
const newOnEnd = onStart(entry.target, entry);
|
|
21
22
|
if (typeof newOnEnd === "function") {
|
|
22
23
|
activeIntersections.set(entry.target, newOnEnd);
|
|
23
24
|
}
|
|
@@ -25,7 +26,7 @@ function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount =
|
|
|
25
26
|
observer.unobserve(entry.target);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
else if (onEnd) {
|
|
29
|
+
else if (typeof onEnd === "function") {
|
|
29
30
|
onEnd(entry);
|
|
30
31
|
activeIntersections.delete(entry.target);
|
|
31
32
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { buildHTMLStyles } from './utils/build-styles.mjs';
|
|
2
|
-
import { isCSSVariableName } from '../dom/utils/is-css-variable.mjs';
|
|
3
|
-
import { transformProps } from './utils/transform.mjs';
|
|
4
|
-
import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.mjs';
|
|
5
|
-
import { renderHTML } from './utils/render.mjs';
|
|
6
|
-
import { getDefaultValueType } from '../dom/value-types/defaults.mjs';
|
|
7
1
|
import { measureViewportBox } from '../../projection/utils/measure.mjs';
|
|
8
2
|
import { DOMVisualElement } from '../dom/DOMVisualElement.mjs';
|
|
9
|
-
import {
|
|
3
|
+
import { isCSSVariableName } from '../dom/utils/is-css-variable.mjs';
|
|
4
|
+
import { getDefaultValueType } from '../dom/value-types/defaults.mjs';
|
|
5
|
+
import { buildHTMLStyles } from './utils/build-styles.mjs';
|
|
6
|
+
import { transformProps } from './utils/keys-transform.mjs';
|
|
7
|
+
import { renderHTML } from './utils/render.mjs';
|
|
8
|
+
import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.mjs';
|
|
10
9
|
|
|
11
10
|
function getComputedStyle(element) {
|
|
12
11
|
return window.getComputedStyle(element);
|
|
@@ -39,19 +38,6 @@ class HTMLVisualElement extends DOMVisualElement {
|
|
|
39
38
|
scrapeMotionValuesFromProps(props, prevProps, visualElement) {
|
|
40
39
|
return scrapeMotionValuesFromProps(props, prevProps, visualElement);
|
|
41
40
|
}
|
|
42
|
-
handleChildMotionValue() {
|
|
43
|
-
if (this.childSubscription) {
|
|
44
|
-
this.childSubscription();
|
|
45
|
-
delete this.childSubscription;
|
|
46
|
-
}
|
|
47
|
-
const { children } = this.props;
|
|
48
|
-
if (isMotionValue(children)) {
|
|
49
|
-
this.childSubscription = children.on("change", (latest) => {
|
|
50
|
-
if (this.current)
|
|
51
|
-
this.current.textContent = `${latest}`;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
41
|
}
|
|
56
42
|
|
|
57
43
|
export { HTMLVisualElement, getComputedStyle };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { buildTransform } from './build-transform.mjs';
|
|
2
1
|
import { isCSSVariableName } from '../../dom/utils/is-css-variable.mjs';
|
|
3
|
-
import { transformProps } from './transform.mjs';
|
|
4
2
|
import { getValueAsType } from '../../dom/value-types/get-as-type.mjs';
|
|
5
3
|
import { numberValueTypes } from '../../dom/value-types/number.mjs';
|
|
4
|
+
import { buildTransform } from './build-transform.mjs';
|
|
5
|
+
import { transformProps } from './keys-transform.mjs';
|
|
6
6
|
|
|
7
7
|
function buildHTMLStyles(state, latestValues, transformTemplate) {
|
|
8
8
|
const { style, vars, transformOrigin } = state;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { transformPropOrder } from './transform.mjs';
|
|
2
1
|
import { getValueAsType } from '../../dom/value-types/get-as-type.mjs';
|
|
3
2
|
import { numberValueTypes } from '../../dom/value-types/number.mjs';
|
|
3
|
+
import { transformPropOrder } from './keys-transform.mjs';
|
|
4
4
|
|
|
5
5
|
const translateAlias = {
|
|
6
6
|
x: "translateX",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createBox } from '../../projection/geometry/models.mjs';
|
|
2
2
|
import { DOMVisualElement } from '../dom/DOMVisualElement.mjs';
|
|
3
|
-
import { buildSVGAttrs } from './utils/build-attrs.mjs';
|
|
4
3
|
import { camelToDash } from '../dom/utils/camel-to-dash.mjs';
|
|
5
|
-
import { camelCaseAttributes } from './utils/camel-case-attrs.mjs';
|
|
6
|
-
import { transformProps } from '../html/utils/transform.mjs';
|
|
7
|
-
import { renderSVG } from './utils/render.mjs';
|
|
8
4
|
import { getDefaultValueType } from '../dom/value-types/defaults.mjs';
|
|
9
|
-
import {
|
|
5
|
+
import { transformProps } from '../html/utils/keys-transform.mjs';
|
|
6
|
+
import { buildSVGAttrs } from './utils/build-attrs.mjs';
|
|
7
|
+
import { camelCaseAttributes } from './utils/camel-case-attrs.mjs';
|
|
10
8
|
import { isSVGTag } from './utils/is-svg-tag.mjs';
|
|
9
|
+
import { renderSVG } from './utils/render.mjs';
|
|
10
|
+
import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.mjs';
|
|
11
11
|
|
|
12
12
|
class SVGVisualElement extends DOMVisualElement {
|
|
13
13
|
constructor() {
|
|
@@ -1,37 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.mjs';
|
|
1
|
+
import { frame } from '../../frameloop/frame.mjs';
|
|
3
2
|
import { makeUseVisualState } from '../../motion/utils/use-visual-state.mjs';
|
|
4
|
-
import {
|
|
3
|
+
import { transformProps } from '../html/utils/keys-transform.mjs';
|
|
5
4
|
import { buildSVGAttrs } from './utils/build-attrs.mjs';
|
|
5
|
+
import { createSvgRenderState } from './utils/create-render-state.mjs';
|
|
6
6
|
import { isSVGTag } from './utils/is-svg-tag.mjs';
|
|
7
|
-
import {
|
|
7
|
+
import { renderSVG } from './utils/render.mjs';
|
|
8
|
+
import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.mjs';
|
|
8
9
|
|
|
10
|
+
function updateSVGDimensions(instance, renderState) {
|
|
11
|
+
try {
|
|
12
|
+
renderState.dimensions =
|
|
13
|
+
typeof instance.getBBox === "function"
|
|
14
|
+
? instance.getBBox()
|
|
15
|
+
: instance.getBoundingClientRect();
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
// Most likely trying to measure an unrendered element under Firefox
|
|
19
|
+
renderState.dimensions = {
|
|
20
|
+
x: 0,
|
|
21
|
+
y: 0,
|
|
22
|
+
width: 0,
|
|
23
|
+
height: 0,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const layoutProps = ["x", "y", "width", "height", "cx", "cy", "r"];
|
|
9
28
|
const svgMotionConfig = {
|
|
10
29
|
useVisualState: makeUseVisualState({
|
|
11
30
|
scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
|
|
12
31
|
createRenderState: createSvgRenderState,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
onUpdate: ({ props, prevProps, current, renderState, latestValues, }) => {
|
|
33
|
+
if (!current)
|
|
34
|
+
return;
|
|
35
|
+
let hasTransform = !!props.drag;
|
|
36
|
+
if (!hasTransform) {
|
|
37
|
+
for (const key in latestValues) {
|
|
38
|
+
if (transformProps.has(key)) {
|
|
39
|
+
hasTransform = true;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
21
42
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
43
|
+
}
|
|
44
|
+
if (!hasTransform)
|
|
45
|
+
return;
|
|
46
|
+
let needsMeasure = !prevProps;
|
|
47
|
+
if (prevProps) {
|
|
48
|
+
/**
|
|
49
|
+
* Check the layout props for changes, if any are found we need to
|
|
50
|
+
* measure the element again.
|
|
51
|
+
*/
|
|
52
|
+
for (let i = 0; i < layoutProps.length; i++) {
|
|
53
|
+
const key = layoutProps[i];
|
|
54
|
+
if (props[key] !==
|
|
55
|
+
prevProps[key]) {
|
|
56
|
+
needsMeasure = true;
|
|
57
|
+
}
|
|
30
58
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
59
|
+
}
|
|
60
|
+
if (!needsMeasure)
|
|
61
|
+
return;
|
|
62
|
+
frame.read(() => {
|
|
63
|
+
updateSVGDimensions(current, renderState);
|
|
64
|
+
frame.render(() => {
|
|
65
|
+
buildSVGAttrs(renderState, latestValues, isSVGTag(current.tagName), props.transformTemplate);
|
|
66
|
+
renderSVG(current, renderState);
|
|
67
|
+
});
|
|
35
68
|
});
|
|
36
69
|
},
|
|
37
70
|
}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildHTMLStyles } from '../../html/utils/build-styles.mjs';
|
|
2
|
-
import { calcSVGTransformOrigin } from './transform-origin.mjs';
|
|
3
2
|
import { buildSVGPath } from './path.mjs';
|
|
3
|
+
import { calcSVGTransformOrigin } from './transform-origin.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Build SVG visual attrbutes, like cx and style.transform
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isMotionValue } from '../../../value/utils/is-motion-value.mjs';
|
|
2
|
+
import { transformPropOrder } from '../../html/utils/keys-transform.mjs';
|
|
2
3
|
import { scrapeMotionValuesFromProps as scrapeMotionValuesFromProps$1 } from '../../html/utils/scrape-motion-values.mjs';
|
|
3
|
-
import { transformPropOrder } from '../../html/utils/transform.mjs';
|
|
4
4
|
|
|
5
5
|
function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
|
|
6
6
|
const newValues = scrapeMotionValuesFromProps$1(props, prevProps, visualElement);
|
|
@@ -17,7 +17,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
17
17
|
* and warn against mismatches.
|
|
18
18
|
*/
|
|
19
19
|
if (process.env.NODE_ENV === "development") {
|
|
20
|
-
warnOnce(nextValue.version === "12.0.
|
|
20
|
+
warnOnce(nextValue.version === "12.0.1", `Attempting to mix Motion versions ${nextValue.version} with 12.0.1 may not work as expected.`);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
else if (isMotionValue(prevValue)) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import '../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { secondsToMilliseconds } from '../../../../motion-utils/dist/es/time-conversion.mjs';
|
|
1
3
|
import { time } from '../frameloop/sync-time.mjs';
|
|
2
|
-
import { secondsToMilliseconds } from './time-conversion.mjs';
|
|
3
4
|
import { frame, cancelFrame } from '../frameloop/frame.mjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { invariant } from '
|
|
1
|
+
import { invariant } from '../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { noop } from '../../../../motion-utils/dist/es/noop.mjs';
|
|
3
|
+
import { progress } from '../../../../motion-utils/dist/es/progress.mjs';
|
|
2
4
|
import { clamp } from './clamp.mjs';
|
|
3
|
-
import { pipe } from './pipe.mjs';
|
|
4
|
-
import { progress } from './progress.mjs';
|
|
5
|
-
import { noop } from './noop.mjs';
|
|
6
5
|
import { mix } from './mix/index.mjs';
|
|
6
|
+
import { pipe } from './pipe.mjs';
|
|
7
7
|
|
|
8
8
|
function createMixers(output, ease, customMixer) {
|
|
9
9
|
const mixers = [];
|
|
@@ -47,8 +47,9 @@ function interpolate(input, output, { clamp: isClamp = true, ease, mixer } = {})
|
|
|
47
47
|
*/
|
|
48
48
|
if (inputLength === 1)
|
|
49
49
|
return () => output[0];
|
|
50
|
-
if (inputLength === 2 &&
|
|
50
|
+
if (inputLength === 2 && output[0] === output[1])
|
|
51
51
|
return () => output[1];
|
|
52
|
+
const isZeroDeltaRange = input[0] === input[1];
|
|
52
53
|
// If input runs highest -> lowest, reverse both arrays
|
|
53
54
|
if (input[0] > input[inputLength - 1]) {
|
|
54
55
|
input = [...input].reverse();
|
|
@@ -57,6 +58,8 @@ function interpolate(input, output, { clamp: isClamp = true, ease, mixer } = {})
|
|
|
57
58
|
const mixers = createMixers(output, ease, mixer);
|
|
58
59
|
const numMixers = mixers.length;
|
|
59
60
|
const interpolator = (v) => {
|
|
61
|
+
if (isZeroDeltaRange && v < input[0])
|
|
62
|
+
return output[0];
|
|
60
63
|
let i = 0;
|
|
61
64
|
if (numMixers > 1) {
|
|
62
65
|
for (; i < input.length - 2; i++) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mixNumber } from './number.mjs';
|
|
2
|
-
import { warning } from '
|
|
2
|
+
import { warning } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
3
3
|
import { hslaToRgba } from '../hsla-to-rgba.mjs';
|
|
4
4
|
import { hex } from '../../value/types/color/hex.mjs';
|
|
5
5
|
import { rgba } from '../../value/types/color/rgba.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mixNumber as mixNumber$1 } from './number.mjs';
|
|
2
2
|
import { mixColor } from './color.mjs';
|
|
3
3
|
import { pipe } from '../pipe.mjs';
|
|
4
|
-
import { warning } from '
|
|
4
|
+
import { warning } from '../../../../../motion-utils/dist/es/errors.mjs';
|
|
5
5
|
import { color } from '../../value/types/color/index.mjs';
|
|
6
6
|
import { complex, analyseComplexValue } from '../../value/types/complex/index.mjs';
|
|
7
7
|
import { isCSSVariableToken } from '../../render/dom/utils/is-css-variable.mjs';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import '../../../../../motion-utils/dist/es/errors.mjs';
|
|
2
|
+
import { progress } from '../../../../../motion-utils/dist/es/progress.mjs';
|
|
1
3
|
import { mixNumber } from '../mix/number.mjs';
|
|
2
|
-
import { progress } from '../progress.mjs';
|
|
3
4
|
|
|
4
5
|
function fillOffset(offset, remaining) {
|
|
5
6
|
const min = offset[offset.length - 1];
|