motion-start 0.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 +21 -0
- package/README.md +39 -0
- package/package.json +64 -0
- package/src/animation/UseAnimatedState.svelte +86 -0
- package/src/animation/UseAnimation.svelte +61 -0
- package/src/animation/animate.ts +78 -0
- package/src/animation/animation-controls.ts +101 -0
- package/src/animation/types.ts +83 -0
- package/src/animation/use-animated-state.ts +1 -0
- package/src/animation/use-animation.ts +74 -0
- package/src/animation/utils/default-transitions.ts +70 -0
- package/src/animation/utils/easing.ts +55 -0
- package/src/animation/utils/is-animatable.ts +42 -0
- package/src/animation/utils/is-animation-controls.ts +17 -0
- package/src/animation/utils/is-keyframes-target.ts +17 -0
- package/src/animation/utils/transitions.ts +218 -0
- package/src/animation/utils/variant-resolvers.ts +15 -0
- package/src/components/AnimatePresence/AnimatePresence.svelte +180 -0
- package/src/components/AnimatePresence/PresenceChild/PresenceChild.svelte +78 -0
- package/src/components/AnimatePresence/PresenceChild/index.ts +7 -0
- package/src/components/AnimatePresence/PresenceChild/types.ts +10 -0
- package/src/components/AnimatePresence/index.ts +46 -0
- package/src/components/AnimatePresence/types.ts +79 -0
- package/src/components/AnimatePresence/use-presence.ts +90 -0
- package/src/components/AnimateSharedLayout/AnimateSharedLayout.svelte +239 -0
- package/src/components/AnimateSharedLayout/index.ts +11 -0
- package/src/components/AnimateSharedLayout/types.ts +111 -0
- package/src/components/AnimateSharedLayout/utils/batcher.ts +96 -0
- package/src/components/AnimateSharedLayout/utils/crossfader.ts +260 -0
- package/src/components/AnimateSharedLayout/utils/rotate.ts +48 -0
- package/src/components/AnimateSharedLayout/utils/stack.ts +160 -0
- package/src/components/LazyMotion/LazyMotion.svelte +82 -0
- package/src/components/LazyMotion/index.ts +42 -0
- package/src/components/LazyMotion/types.ts +58 -0
- package/src/components/MotionConfig/MotionConfig.svelte +56 -0
- package/src/components/MotionConfig/MotionConfigScaleCorrection.ts +47 -0
- package/src/components/MotionConfig/index.ts +20 -0
- package/src/components/MotionDiv.svelte +8 -0
- package/src/context/DOMcontext.ts +21 -0
- package/src/context/LayoutGroupContext.ts +13 -0
- package/src/context/LazyContext.ts +18 -0
- package/src/context/MotionConfigContext.ts +48 -0
- package/src/context/MotionContext/MotionContext.svelte +27 -0
- package/src/context/MotionContext/MotionContextProvider.svelte +22 -0
- package/src/context/MotionContext/UseCreateMotionContext.svelte +34 -0
- package/src/context/MotionContext/create.ts +1 -0
- package/src/context/MotionContext/index.ts +14 -0
- package/src/context/MotionContext/utils.ts +29 -0
- package/src/context/PresenceContext.ts +26 -0
- package/src/context/ScaleCorrectionProvider.svelte +27 -0
- package/src/context/SharedLayoutContext.ts +29 -0
- package/src/events/UseDomEvent.svelte +67 -0
- package/src/events/UsePointerEvent.svelte +76 -0
- package/src/events/event-info.ts +69 -0
- package/src/events/types.ts +15 -0
- package/src/events/use-dom-event.ts +48 -0
- package/src/events/use-pointer-event.ts +29 -0
- package/src/events/utils.ts +25 -0
- package/src/gestures/PanSession.ts +298 -0
- package/src/gestures/UseFocusGesture.svelte +31 -0
- package/src/gestures/UseGestures.svelte +17 -0
- package/src/gestures/UseHoverGesture.svelte +40 -0
- package/src/gestures/UsePanGesture.svelte +58 -0
- package/src/gestures/UseTapGesture.svelte +77 -0
- package/src/gestures/drag/UseDrag.svelte +55 -0
- package/src/gestures/drag/UseDragControls.svelte +145 -0
- package/src/gestures/drag/VisualElementDragControls.ts +632 -0
- package/src/gestures/drag/types.ts +307 -0
- package/src/gestures/drag/use-drag-controls.ts +148 -0
- package/src/gestures/drag/use-drag.ts +15 -0
- package/src/gestures/drag/utils/constraints.ts +157 -0
- package/src/gestures/drag/utils/lock.ts +69 -0
- package/src/gestures/types.ts +257 -0
- package/src/gestures/use-focus-gesture.ts +16 -0
- package/src/gestures/use-gestures.ts +2 -0
- package/src/gestures/use-hover-gesture.ts +10 -0
- package/src/gestures/use-pan-gesture.ts +22 -0
- package/src/gestures/use-tap-gesture.ts +14 -0
- package/src/gestures/utils/event-type.ts +24 -0
- package/src/gestures/utils/is-node-or-child.ts +31 -0
- package/src/index.ts +104 -0
- package/src/motion/Motion.svelte +246 -0
- package/src/motion/MotionSSR.svelte +244 -0
- package/src/motion/features/AnimationState.svelte +29 -0
- package/src/motion/features/Exit.svelte +32 -0
- package/src/motion/features/UseFeatures.svelte +39 -0
- package/src/motion/features/animations.ts +22 -0
- package/src/motion/features/definitions.ts +49 -0
- package/src/motion/features/drag.ts +24 -0
- package/src/motion/features/gestures.ts +24 -0
- package/src/motion/features/layout/Animate.svelte +314 -0
- package/src/motion/features/layout/Animate.ts +9 -0
- package/src/motion/features/layout/AnimateLayoutContextProvider.svelte +14 -0
- package/src/motion/features/layout/Measure.svelte +98 -0
- package/src/motion/features/layout/Measure.ts +9 -0
- package/src/motion/features/layout/MeasureContextProvider.svelte +32 -0
- package/src/motion/features/layout/index.ts +20 -0
- package/src/motion/features/layout/types.ts +71 -0
- package/src/motion/features/layout/utils.ts +40 -0
- package/src/motion/features/types.ts +53 -0
- package/src/motion/features/use-features.ts +16 -0
- package/src/motion/index.ts +64 -0
- package/src/motion/types.ts +278 -0
- package/src/motion/utils/UseLayoutId.svelte +18 -0
- package/src/motion/utils/UseVisualElement.svelte +104 -0
- package/src/motion/utils/UseVisualState.svelte +137 -0
- package/src/motion/utils/is-forced-motion-value.ts +23 -0
- package/src/motion/utils/make-renderless-component.ts +17 -0
- package/src/motion/utils/should-inhert-variant.ts +6 -0
- package/src/motion/utils/use-motion-ref.ts +41 -0
- package/src/motion/utils/use-visual-element.ts +13 -0
- package/src/motion/utils/use-visual-state.ts +24 -0
- package/src/motion/utils/valid-prop.ts +80 -0
- package/src/render/dom/M.svelte +16 -0
- package/src/render/dom/UseRender.svelte +37 -0
- package/src/render/dom/create-motion-class.ts +12 -0
- package/src/render/dom/create-visual-element.ts +22 -0
- package/src/render/dom/featureBundle.ts +22 -0
- package/src/render/dom/motion-minimal.ts +22 -0
- package/src/render/dom/motion-proxy.ts +107 -0
- package/src/render/dom/motion.ts +62 -0
- package/src/render/dom/projection/convert-to-relative.ts +40 -0
- package/src/render/dom/projection/default-scale-correctors.ts +138 -0
- package/src/render/dom/projection/measure.ts +28 -0
- package/src/render/dom/projection/relative-set.ts +27 -0
- package/src/render/dom/projection/scale-correction.ts +22 -0
- package/src/render/dom/projection/types.ts +13 -0
- package/src/render/dom/projection/utils.ts +69 -0
- package/src/render/dom/svg-visual-element.ts +114 -0
- package/src/render/dom/types.ts +32 -0
- package/src/render/dom/use-render.ts +11 -0
- package/src/render/dom/utils/UseInitialMotionProps.svelte +26 -0
- package/src/render/dom/utils/batch-layout.ts +77 -0
- package/src/render/dom/utils/camel-to-dash.ts +20 -0
- package/src/render/dom/utils/create-config.ts +33 -0
- package/src/render/dom/utils/css-variables-conversion.ts +121 -0
- package/src/render/dom/utils/filter-props.ts +55 -0
- package/src/render/dom/utils/is-css-variable.ts +18 -0
- package/src/render/dom/utils/is-svg-component.ts +41 -0
- package/src/render/dom/utils/parse-dom-variant.ts +26 -0
- package/src/render/dom/utils/unit-conversion.ts +258 -0
- package/src/render/dom/utils/use-html-props.ts +2 -0
- package/src/render/dom/utils/use-svg-props.ts +1 -0
- package/src/render/dom/value-types/animatable-none.ts +24 -0
- package/src/render/dom/value-types/defaults.ts +30 -0
- package/src/render/dom/value-types/dimensions.ts +27 -0
- package/src/render/dom/value-types/find.ts +31 -0
- package/src/render/dom/value-types/get-as-type.ts +21 -0
- package/src/render/dom/value-types/number.ts +83 -0
- package/src/render/dom/value-types/test.ts +17 -0
- package/src/render/dom/value-types/type-auto.ts +21 -0
- package/src/render/dom/value-types/type-int.ts +23 -0
- package/src/render/dom/value-types/types.ts +8 -0
- package/src/render/html/UseHTMLProps.svelte +33 -0
- package/src/render/html/UseInitialMotionValues.svelte +27 -0
- package/src/render/html/UseStyle.svelte +47 -0
- package/src/render/html/config-motion.ts +23 -0
- package/src/render/html/supported-elements.ts +10 -0
- package/src/render/html/types.ts +64 -0
- package/src/render/html/use-props.ts +14 -0
- package/src/render/html/utils/build-projection-transform.ts +53 -0
- package/src/render/html/utils/build-styles.ts +121 -0
- package/src/render/html/utils/build-transform.ts +79 -0
- package/src/render/html/utils/create-render-state.ts +18 -0
- package/src/render/html/utils/render.ts +22 -0
- package/src/render/html/utils/scrape-motion-values.ts +26 -0
- package/src/render/html/utils/transform.ts +51 -0
- package/src/render/html/visual-element.ts +129 -0
- package/src/render/index.ts +703 -0
- package/src/render/svg/UseSVGProps.svelte +34 -0
- package/src/render/svg/config-motion.ts +51 -0
- package/src/render/svg/lowercase-elements.ts +35 -0
- package/src/render/svg/supported-elements.ts +10 -0
- package/src/render/svg/types.ts +51 -0
- package/src/render/svg/use-props.ts +14 -0
- package/src/render/svg/utils/build-attrs.ts +58 -0
- package/src/render/svg/utils/camel-case-attrs.ts +27 -0
- package/src/render/svg/utils/create-render-state.ts +17 -0
- package/src/render/svg/utils/path.ts +49 -0
- package/src/render/svg/utils/render.ts +22 -0
- package/src/render/svg/utils/scrape-motion-values.ts +26 -0
- package/src/render/svg/utils/transform-origin.ts +30 -0
- package/src/render/svg/visual-element.ts +44 -0
- package/src/render/types.ts +148 -0
- package/src/render/utils/animation-state.ts +375 -0
- package/src/render/utils/animation.ts +167 -0
- package/src/render/utils/compare-by-depth.ts +18 -0
- package/src/render/utils/flat-tree.ts +35 -0
- package/src/render/utils/is-draggable.ts +17 -0
- package/src/render/utils/lifecycles.ts +172 -0
- package/src/render/utils/motion-values.ts +59 -0
- package/src/render/utils/projection.ts +38 -0
- package/src/render/utils/setters.ts +910 -0
- package/src/render/utils/state.ts +113 -0
- package/src/render/utils/types.ts +12 -0
- package/src/render/utils/variants.ts +76 -0
- package/src/types/geometry.ts +91 -0
- package/src/types.ts +1088 -0
- package/src/utils/UseUnmountEffect.svelte +11 -0
- package/src/utils/array.ts +18 -0
- package/src/utils/each-axis.ts +15 -0
- package/src/utils/errors.ts +22 -0
- package/src/utils/fix-process-env.ts +22 -0
- package/src/utils/geometry/delta-apply.ts +162 -0
- package/src/utils/geometry/delta-calc.ts +89 -0
- package/src/utils/geometry/index.ts +83 -0
- package/src/utils/is-browser.ts +12 -0
- package/src/utils/is-numerical-string.ts +15 -0
- package/src/utils/is-ref-object.ts +16 -0
- package/src/utils/noop.ts +15 -0
- package/src/utils/resolve-value.ts +23 -0
- package/src/utils/shallow-compare.ts +23 -0
- package/src/utils/subscription-manager.ts +49 -0
- package/src/utils/time-conversion.ts +18 -0
- package/src/utils/transform.ts +120 -0
- package/src/utils/use-constant.ts +23 -0
- package/src/utils/use-cycle.ts +78 -0
- package/src/utils/use-force-update.ts +7 -0
- package/src/utils/use-isomorphic-effect.ts +8 -0
- package/src/utils/use-reduced-motion.ts +70 -0
- package/src/utils/use-unmount-effect.ts +8 -0
- package/src/value/index.ts +409 -0
- package/src/value/scroll/use-element-scroll.ts +73 -0
- package/src/value/scroll/use-viewport-scroll.ts +81 -0
- package/src/value/scroll/utils.ts +76 -0
- package/src/value/use-combine-values.ts +53 -0
- package/src/value/use-motion-template.ts +57 -0
- package/src/value/use-motion-value.ts +27 -0
- package/src/value/use-spring.ts +84 -0
- package/src/value/use-transform.ts +216 -0
- package/src/value/use-velocity.ts +44 -0
- package/src/value/utils/is-motion-value.ts +15 -0
- package/src/value/utils/resolve-motion-value.ts +29 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { ComponentType } from "react";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
import { lowercaseSVGElements } from '../../svg/lowercase-elements.js';
|
|
13
|
+
|
|
14
|
+
function isSVGComponent(Component: string | ComponentType) {
|
|
15
|
+
if (
|
|
16
|
+
/**
|
|
17
|
+
* If it's not a string, it's a custom React component. Currently we only support
|
|
18
|
+
* HTML custom React components.
|
|
19
|
+
*/
|
|
20
|
+
typeof Component !== "string" ||
|
|
21
|
+
/**
|
|
22
|
+
* If it contains a dash, the element is a custom HTML webcomponent.
|
|
23
|
+
*/
|
|
24
|
+
Component.includes("-")) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
else if (
|
|
28
|
+
/**
|
|
29
|
+
* If it's in our list of lowercase SVG tags, it's an SVG component
|
|
30
|
+
*/
|
|
31
|
+
lowercaseSVGElements.indexOf(Component) > -1 ||
|
|
32
|
+
/**
|
|
33
|
+
* If it contains a capital letter, it's an SVG component
|
|
34
|
+
*/
|
|
35
|
+
/[A-Z]/.test(Component)) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { isSVGComponent };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { MakeTargetAnimatable } from "../../utils/animation";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
import { resolveCSSVariables } from './css-variables-conversion.js';
|
|
13
|
+
import { unitConversion } from './unit-conversion.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Parse a DOM variant to make it animatable. This involves resolving CSS variables
|
|
17
|
+
* and ensuring animations like "20%" => "calc(50vw)" are performed in pixels.
|
|
18
|
+
*/
|
|
19
|
+
var parseDomVariant: MakeTargetAnimatable = function (visualElement, target, origin, transitionEnd) {
|
|
20
|
+
var resolved = resolveCSSVariables(visualElement, target, transitionEnd);
|
|
21
|
+
target = resolved.target;
|
|
22
|
+
transitionEnd = resolved.transitionEnd;
|
|
23
|
+
return unitConversion(visualElement, target, origin, transitionEnd);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { parseDomVariant };
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { Target, TargetWithKeyframes } from "../../../types";
|
|
6
|
+
import type { VisualElement } from "../../types";
|
|
7
|
+
enum BoundingBoxDimension {
|
|
8
|
+
width = "width",
|
|
9
|
+
height = "height",
|
|
10
|
+
left = "left",
|
|
11
|
+
right = "right",
|
|
12
|
+
top = "top",
|
|
13
|
+
bottom = "bottom"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
based on framer-motion@4.0.3,
|
|
18
|
+
Copyright (c) 2018 Framer B.V.
|
|
19
|
+
*/
|
|
20
|
+
import {fixed} from '../../../utils/fix-process-env.js';
|
|
21
|
+
import { __assign, __read } from 'tslib';
|
|
22
|
+
import { number, px } from 'style-value-types';
|
|
23
|
+
import { isKeyframesTarget } from '../../../animation/utils/is-keyframes-target.js';
|
|
24
|
+
// import { invariant } from '../../../utils/errors.js';
|
|
25
|
+
import { transformProps } from '../../html/utils/transform.js';
|
|
26
|
+
import { findDimensionValueType } from '../value-types/dimensions.js';
|
|
27
|
+
|
|
28
|
+
var positionalKeys = new Set([
|
|
29
|
+
"width",
|
|
30
|
+
"height",
|
|
31
|
+
"top",
|
|
32
|
+
"left",
|
|
33
|
+
"right",
|
|
34
|
+
"bottom",
|
|
35
|
+
"x",
|
|
36
|
+
"y",
|
|
37
|
+
]);
|
|
38
|
+
var isPositionalKey = function (key) { return positionalKeys.has(key); };
|
|
39
|
+
var hasPositionalKey = function (target) {
|
|
40
|
+
return Object.keys(target).some(isPositionalKey);
|
|
41
|
+
};
|
|
42
|
+
var setAndResetVelocity = function (value, to) {
|
|
43
|
+
// Looks odd but setting it twice doesn't render, it'll just
|
|
44
|
+
// set both prev and current to the latest value
|
|
45
|
+
value.set(to, false);
|
|
46
|
+
value.set(to);
|
|
47
|
+
};
|
|
48
|
+
var isNumOrPxType = function (v) {
|
|
49
|
+
return v === number || v === px;
|
|
50
|
+
};
|
|
51
|
+
var getPosFromMatrix = function (matrix, pos) {
|
|
52
|
+
return parseFloat(matrix.split(", ")[pos]);
|
|
53
|
+
};
|
|
54
|
+
var getTranslateFromMatrix = function (pos2, pos3) { return function (_bbox, _a) {
|
|
55
|
+
var transform = _a.transform;
|
|
56
|
+
if (transform === "none" || !transform)
|
|
57
|
+
return 0;
|
|
58
|
+
var matrix3d = transform.match(/^matrix3d\((.+)\)$/);
|
|
59
|
+
if (matrix3d) {
|
|
60
|
+
return getPosFromMatrix(matrix3d[1], pos3);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
var matrix = transform.match(/^matrix\((.+)\)$/);
|
|
64
|
+
if (matrix) {
|
|
65
|
+
return getPosFromMatrix(matrix[1], pos2);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}; };
|
|
72
|
+
var transformKeys = new Set(["x", "y", "z"]);
|
|
73
|
+
var nonTranslationalTransformKeys = transformProps.filter(function (key) { return !transformKeys.has(key); });
|
|
74
|
+
function removeNonTranslationalTransform(visualElement) {
|
|
75
|
+
var removedTransforms = [];
|
|
76
|
+
nonTranslationalTransformKeys.forEach(function (key) {
|
|
77
|
+
var value = visualElement.getValue(key);
|
|
78
|
+
if (value !== undefined) {
|
|
79
|
+
removedTransforms.push([key, value.get()]);
|
|
80
|
+
value.set(key.startsWith("scale") ? 1 : 0);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
// Apply changes to element before measurement
|
|
84
|
+
if (removedTransforms.length)
|
|
85
|
+
visualElement.syncRender();
|
|
86
|
+
return removedTransforms;
|
|
87
|
+
}
|
|
88
|
+
var positionalValues = {
|
|
89
|
+
// Dimensions
|
|
90
|
+
width: function (_a) {
|
|
91
|
+
var x = _a.x;
|
|
92
|
+
return x.max - x.min;
|
|
93
|
+
},
|
|
94
|
+
height: function (_a) {
|
|
95
|
+
var y = _a.y;
|
|
96
|
+
return y.max - y.min;
|
|
97
|
+
},
|
|
98
|
+
top: function (_bbox, _a) {
|
|
99
|
+
var top = _a.top;
|
|
100
|
+
return parseFloat(top);
|
|
101
|
+
},
|
|
102
|
+
left: function (_bbox, _a) {
|
|
103
|
+
var left = _a.left;
|
|
104
|
+
return parseFloat(left);
|
|
105
|
+
},
|
|
106
|
+
bottom: function (_a, _b) {
|
|
107
|
+
var y = _a.y;
|
|
108
|
+
var top = _b.top;
|
|
109
|
+
return parseFloat(top) + (y.max - y.min);
|
|
110
|
+
},
|
|
111
|
+
right: function (_a, _b) {
|
|
112
|
+
var x = _a.x;
|
|
113
|
+
var left = _b.left;
|
|
114
|
+
return parseFloat(left) + (x.max - x.min);
|
|
115
|
+
},
|
|
116
|
+
// Transform
|
|
117
|
+
x: getTranslateFromMatrix(4, 13),
|
|
118
|
+
y: getTranslateFromMatrix(5, 14),
|
|
119
|
+
};
|
|
120
|
+
var convertChangedValueTypes = function (target, visualElement, changedKeys) {
|
|
121
|
+
var originBbox = visualElement.measureViewportBox();
|
|
122
|
+
var element = visualElement.getInstance();
|
|
123
|
+
var elementComputedStyle = getComputedStyle(element);
|
|
124
|
+
var display = elementComputedStyle.display, top = elementComputedStyle.top, left = elementComputedStyle.left, bottom = elementComputedStyle.bottom, right = elementComputedStyle.right, transform = elementComputedStyle.transform;
|
|
125
|
+
var originComputedStyle = { top: top, left: left, bottom: bottom, right: right, transform: transform };
|
|
126
|
+
// If the element is currently set to display: "none", make it visible before
|
|
127
|
+
// measuring the target bounding box
|
|
128
|
+
if (display === "none") {
|
|
129
|
+
visualElement.setStaticValue("display", target.display || "block");
|
|
130
|
+
}
|
|
131
|
+
// Apply the latest values (as set in checkAndConvertChangedValueTypes)
|
|
132
|
+
visualElement.syncRender();
|
|
133
|
+
var targetBbox = visualElement.measureViewportBox();
|
|
134
|
+
changedKeys.forEach(function (key) {
|
|
135
|
+
// Restore styles to their **calculated computed style**, not their actual
|
|
136
|
+
// originally set style. This allows us to animate between equivalent pixel units.
|
|
137
|
+
var value = visualElement.getValue(key);
|
|
138
|
+
setAndResetVelocity(value, positionalValues[key](originBbox, originComputedStyle));
|
|
139
|
+
target[key] = positionalValues[key](targetBbox, elementComputedStyle);
|
|
140
|
+
});
|
|
141
|
+
return target;
|
|
142
|
+
};
|
|
143
|
+
var checkAndConvertChangedValueTypes = function (visualElement, target, origin, transitionEnd) {
|
|
144
|
+
if (origin === void 0) { origin = {}; }
|
|
145
|
+
if (transitionEnd === void 0) { transitionEnd = {}; }
|
|
146
|
+
target = __assign({}, target);
|
|
147
|
+
transitionEnd = __assign({}, transitionEnd);
|
|
148
|
+
var targetPositionalKeys = Object.keys(target).filter(isPositionalKey);
|
|
149
|
+
// We want to remove any transform values that could affect the element's bounding box before
|
|
150
|
+
// it's measured. We'll reapply these later.
|
|
151
|
+
var removedTransformValues = [];
|
|
152
|
+
var hasAttemptedToRemoveTransformValues = false;
|
|
153
|
+
var changedValueTypeKeys = [];
|
|
154
|
+
targetPositionalKeys.forEach(function (key) {
|
|
155
|
+
var value = visualElement.getValue(key);
|
|
156
|
+
if (!visualElement.hasValue(key))
|
|
157
|
+
return;
|
|
158
|
+
var from = origin[key];
|
|
159
|
+
var to = target[key];
|
|
160
|
+
var fromType = findDimensionValueType(from);
|
|
161
|
+
var toType;
|
|
162
|
+
// TODO: The current implementation of this basically throws an error
|
|
163
|
+
// if you try and do value conversion via keyframes. There's probably
|
|
164
|
+
// a way of doing this but the performance implications would need greater scrutiny,
|
|
165
|
+
// as it'd be doing multiple resize-remeasure operations.
|
|
166
|
+
if (isKeyframesTarget(to)) {
|
|
167
|
+
var numKeyframes = to.length;
|
|
168
|
+
for (var i = to[0] === null ? 1 : 0; i < numKeyframes; i++) {
|
|
169
|
+
if (!toType) {
|
|
170
|
+
toType = findDimensionValueType(to[i]);
|
|
171
|
+
//invariant(toType === fromType ||
|
|
172
|
+
// (isNumOrPxType(fromType) && isNumOrPxType(toType)), "Keyframes must be of the same dimension as the current value");
|
|
173
|
+
}
|
|
174
|
+
//else {
|
|
175
|
+
/// invariant(findDimensionValueType(to[i]) === toType, "All keyframes must be of the same type");
|
|
176
|
+
//}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
toType = findDimensionValueType(to);
|
|
181
|
+
}
|
|
182
|
+
if (fromType !== toType) {
|
|
183
|
+
// If they're both just number or px, convert them both to numbers rather than
|
|
184
|
+
// relying on resize/remeasure to convert (which is wasteful in this situation)
|
|
185
|
+
if (isNumOrPxType(fromType) && isNumOrPxType(toType)) {
|
|
186
|
+
var current = value.get();
|
|
187
|
+
if (typeof current === "string") {
|
|
188
|
+
value.set(parseFloat(current));
|
|
189
|
+
}
|
|
190
|
+
if (typeof to === "string") {
|
|
191
|
+
target[key] = parseFloat(to);
|
|
192
|
+
}
|
|
193
|
+
else if (Array.isArray(to) && toType === px) {
|
|
194
|
+
target[key] = to.map(parseFloat);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if ((fromType === null || fromType === void 0 ? void 0 : fromType.transform) &&
|
|
198
|
+
(toType === null || toType === void 0 ? void 0 : toType.transform) &&
|
|
199
|
+
(from === 0 || to === 0)) {
|
|
200
|
+
// If one or the other value is 0, it's safe to coerce it to the
|
|
201
|
+
// type of the other without measurement
|
|
202
|
+
if (from === 0) {
|
|
203
|
+
value.set(toType.transform(from));
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
target[key] = fromType.transform(to);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
// If we're going to do value conversion via DOM measurements, we first
|
|
211
|
+
// need to remove non-positional transform values that could affect the bbox measurements.
|
|
212
|
+
if (!hasAttemptedToRemoveTransformValues) {
|
|
213
|
+
removedTransformValues = removeNonTranslationalTransform(visualElement);
|
|
214
|
+
hasAttemptedToRemoveTransformValues = true;
|
|
215
|
+
}
|
|
216
|
+
changedValueTypeKeys.push(key);
|
|
217
|
+
transitionEnd[key] =
|
|
218
|
+
transitionEnd[key] !== undefined
|
|
219
|
+
? transitionEnd[key]
|
|
220
|
+
: target[key];
|
|
221
|
+
setAndResetVelocity(value, to);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
if (changedValueTypeKeys.length) {
|
|
226
|
+
var convertedTarget = convertChangedValueTypes(target, visualElement, changedValueTypeKeys);
|
|
227
|
+
// If we removed transform values, reapply them before the next render
|
|
228
|
+
if (removedTransformValues.length) {
|
|
229
|
+
removedTransformValues.forEach(function (_a) {
|
|
230
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
231
|
+
visualElement.getValue(key).set(value);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
// Reapply original values
|
|
235
|
+
visualElement.syncRender();
|
|
236
|
+
return { target: convertedTarget, transitionEnd: transitionEnd };
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
return { target: target, transitionEnd: transitionEnd };
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Convert value types for x/y/width/height/top/left/bottom/right
|
|
244
|
+
*
|
|
245
|
+
* Allows animation between `'auto'` -> `'100%'` or `0` -> `'calc(50% - 10vw)'`
|
|
246
|
+
*
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
function unitConversion(visualElement: VisualElement, target: TargetWithKeyframes, origin?: Target, transitionEnd?: Target): {
|
|
250
|
+
target: TargetWithKeyframes;
|
|
251
|
+
transitionEnd?: Target;
|
|
252
|
+
} {
|
|
253
|
+
return hasPositionalKey(target)
|
|
254
|
+
? checkAndConvertChangedValueTypes(visualElement, target, origin, transitionEnd)
|
|
255
|
+
: { target: target, transitionEnd: transitionEnd };
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export { BoundingBoxDimension, unitConversion };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as UseSVGProps} from '../../svg/UseSVGProps.svelte';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
based on framer-motion@4.0.3,
|
|
9
|
+
Copyright (c) 2018 Framer B.V.
|
|
10
|
+
*/
|
|
11
|
+
import {fixed} from '../../../utils/fix-process-env.js';
|
|
12
|
+
import { filter, complex } from 'style-value-types';
|
|
13
|
+
import { getDefaultValueType } from './defaults.js';
|
|
14
|
+
|
|
15
|
+
function getAnimatableNone(key:string, value:string) {
|
|
16
|
+
var _a;
|
|
17
|
+
var defaultValueType = getDefaultValueType(key);
|
|
18
|
+
if (defaultValueType !== filter)
|
|
19
|
+
defaultValueType = complex;
|
|
20
|
+
// If value is not recognised as animatable, ie "none", create an animatable version origin based on the target
|
|
21
|
+
return (_a = defaultValueType.getAnimatableNone) === null || _a === void 0 ? void 0 : _a.call(defaultValueType, value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { getAnimatableNone };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { ValueTypeMap } from "./types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
import {fixed} from '../../../utils/fix-process-env.js';
|
|
13
|
+
import { __assign } from 'tslib';
|
|
14
|
+
import { color, filter } from 'style-value-types';
|
|
15
|
+
import { numberValueTypes } from './number.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A map of default value types for common values
|
|
19
|
+
*/
|
|
20
|
+
var defaultValueTypes = __assign(__assign({}, numberValueTypes), {
|
|
21
|
+
// Color props
|
|
22
|
+
color: color, backgroundColor: color, outlineColor: color, fill: color, stroke: color,
|
|
23
|
+
// Border props
|
|
24
|
+
borderColor: color, borderTopColor: color, borderRightColor: color, borderBottomColor: color, borderLeftColor: color, filter: filter, WebkitFilter: filter }) as ValueTypeMap;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the default ValueType for the provided value key
|
|
27
|
+
*/
|
|
28
|
+
var getDefaultValueType = function (key:string) { return defaultValueTypes[key]; };
|
|
29
|
+
|
|
30
|
+
export { defaultValueTypes, getDefaultValueType };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
based on framer-motion@4.0.3,
|
|
9
|
+
Copyright (c) 2018 Framer B.V.
|
|
10
|
+
*/
|
|
11
|
+
import {fixed} from '../../../utils/fix-process-env.js';
|
|
12
|
+
import { number, px, percent, degrees, vw, vh } from 'style-value-types';
|
|
13
|
+
import { testValueType } from './test.js';
|
|
14
|
+
import { auto } from './type-auto.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A list of value types commonly used for dimensions
|
|
18
|
+
*/
|
|
19
|
+
var dimensionValueTypes = [number, px, percent, degrees, vw, vh, auto];
|
|
20
|
+
/**
|
|
21
|
+
* Tests a dimensional value against the list of dimension ValueTypes
|
|
22
|
+
*/
|
|
23
|
+
var findDimensionValueType = function (v) {
|
|
24
|
+
return dimensionValueTypes.find(testValueType(v));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { dimensionValueTypes, findDimensionValueType };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
based on framer-motion@4.0.3,
|
|
9
|
+
Copyright (c) 2018 Framer B.V.
|
|
10
|
+
*/
|
|
11
|
+
import {fixed} from '../../../utils/fix-process-env.js';
|
|
12
|
+
import { __spreadArray, __read } from 'tslib';
|
|
13
|
+
import { color, complex } from 'style-value-types';
|
|
14
|
+
import { dimensionValueTypes } from './dimensions.js';
|
|
15
|
+
import { testValueType } from './test.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A list of all ValueTypes
|
|
19
|
+
*/
|
|
20
|
+
var valueTypes = __spreadArray(__spreadArray([], __read(dimensionValueTypes)), [color, complex]);
|
|
21
|
+
/**
|
|
22
|
+
* Tests a value against the list of ValueTypes
|
|
23
|
+
*/
|
|
24
|
+
var findValueType = function (v: any) { return valueTypes.find(testValueType(v)) as import("style-value-types").ValueType | {
|
|
25
|
+
test: (v: any) => boolean;
|
|
26
|
+
parse: (v: string) => (number | import("style-value-types").RGBA | import("style-value-types").HSLA)[];
|
|
27
|
+
createTransformer: (v: string) => (v: (string | number | import("style-value-types").Color)[]) => string;
|
|
28
|
+
getAnimatableNone: (v: string) => string;
|
|
29
|
+
} | undefined; };
|
|
30
|
+
|
|
31
|
+
export { findValueType };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { ValueType } from "style-value-types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Provided a value and a ValueType, returns the value as that value type.
|
|
14
|
+
*/
|
|
15
|
+
var getValueAsType = function (value: any, type?: ValueType | undefined) {
|
|
16
|
+
return type && typeof value === "number"
|
|
17
|
+
? type.transform(value)
|
|
18
|
+
: value;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { getValueAsType };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { ValueTypeMap } from "./types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
import {fixed} from '../../../utils/fix-process-env.js';
|
|
13
|
+
import { px, degrees, scale, alpha, progressPercentage } from 'style-value-types';
|
|
14
|
+
import { int } from './type-int.js';
|
|
15
|
+
|
|
16
|
+
var numberValueTypes = {
|
|
17
|
+
// Border props
|
|
18
|
+
borderWidth: px,
|
|
19
|
+
borderTopWidth: px,
|
|
20
|
+
borderRightWidth: px,
|
|
21
|
+
borderBottomWidth: px,
|
|
22
|
+
borderLeftWidth: px,
|
|
23
|
+
borderRadius: px,
|
|
24
|
+
radius: px,
|
|
25
|
+
borderTopLeftRadius: px,
|
|
26
|
+
borderTopRightRadius: px,
|
|
27
|
+
borderBottomRightRadius: px,
|
|
28
|
+
borderBottomLeftRadius: px,
|
|
29
|
+
// Positioning props
|
|
30
|
+
width: px,
|
|
31
|
+
maxWidth: px,
|
|
32
|
+
height: px,
|
|
33
|
+
maxHeight: px,
|
|
34
|
+
size: px,
|
|
35
|
+
top: px,
|
|
36
|
+
right: px,
|
|
37
|
+
bottom: px,
|
|
38
|
+
left: px,
|
|
39
|
+
// Spacing props
|
|
40
|
+
padding: px,
|
|
41
|
+
paddingTop: px,
|
|
42
|
+
paddingRight: px,
|
|
43
|
+
paddingBottom: px,
|
|
44
|
+
paddingLeft: px,
|
|
45
|
+
margin: px,
|
|
46
|
+
marginTop: px,
|
|
47
|
+
marginRight: px,
|
|
48
|
+
marginBottom: px,
|
|
49
|
+
marginLeft: px,
|
|
50
|
+
// Transform props
|
|
51
|
+
rotate: degrees,
|
|
52
|
+
rotateX: degrees,
|
|
53
|
+
rotateY: degrees,
|
|
54
|
+
rotateZ: degrees,
|
|
55
|
+
scale: scale,
|
|
56
|
+
scaleX: scale,
|
|
57
|
+
scaleY: scale,
|
|
58
|
+
scaleZ: scale,
|
|
59
|
+
skew: degrees,
|
|
60
|
+
skewX: degrees,
|
|
61
|
+
skewY: degrees,
|
|
62
|
+
distance: px,
|
|
63
|
+
translateX: px,
|
|
64
|
+
translateY: px,
|
|
65
|
+
translateZ: px,
|
|
66
|
+
x: px,
|
|
67
|
+
y: px,
|
|
68
|
+
z: px,
|
|
69
|
+
perspective: px,
|
|
70
|
+
transformPerspective: px,
|
|
71
|
+
opacity: alpha,
|
|
72
|
+
originX: progressPercentage,
|
|
73
|
+
originY: progressPercentage,
|
|
74
|
+
originZ: px,
|
|
75
|
+
// Misc
|
|
76
|
+
zIndex: int,
|
|
77
|
+
// SVG
|
|
78
|
+
fillOpacity: alpha,
|
|
79
|
+
strokeOpacity: alpha,
|
|
80
|
+
numOctaves: int,
|
|
81
|
+
} as ValueTypeMap;
|
|
82
|
+
|
|
83
|
+
export { numberValueTypes };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { ValueType } from "style-value-types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Tests a provided value against a ValueType
|
|
14
|
+
*/
|
|
15
|
+
var testValueType = function (v: any) { return function (type: ValueType) { return type.test(v); }; };
|
|
16
|
+
|
|
17
|
+
export { testValueType };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
import type { ValueType } from "style-value-types";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
based on framer-motion@4.0.3,
|
|
10
|
+
Copyright (c) 2018 Framer B.V.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* ValueType for "auto"
|
|
15
|
+
*/
|
|
16
|
+
var auto = {
|
|
17
|
+
test: function (v) { return v === "auto"; },
|
|
18
|
+
parse: function (v) { return v; },
|
|
19
|
+
} as ValueType;
|
|
20
|
+
|
|
21
|
+
export { auto };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
based on framer-motion@4.1.17,
|
|
3
|
+
Copyright (c) 2018 Framer B.V.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
based on framer-motion@4.0.3,
|
|
8
|
+
Copyright (c) 2018 Framer B.V.
|
|
9
|
+
*/
|
|
10
|
+
import {fixed} from '../../../utils/fix-process-env';
|
|
11
|
+
import { __assign } from 'tslib';
|
|
12
|
+
import { number } from 'style-value-types';
|
|
13
|
+
|
|
14
|
+
var int = __assign(__assign({}, number), { transform: Math.round }) as {
|
|
15
|
+
transform: (x: number) => number;
|
|
16
|
+
test: (v: any) => boolean;
|
|
17
|
+
parse: (v: any) => any;
|
|
18
|
+
createTransformer?: ((template: string) => import("style-value-types").Transformer) | undefined;
|
|
19
|
+
default?: any;
|
|
20
|
+
getAnimatableNone?: ((v: any) => any) | undefined;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { int };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!-- based on framer-motion@4.0.3,
|
|
2
|
+
Copyright (c) 2018 Framer B.V. -->
|
|
3
|
+
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import UseStyle from "./UseStyle.svelte";
|
|
6
|
+
|
|
7
|
+
export let props, visualState, isStatic;
|
|
8
|
+
|
|
9
|
+
const getHTMLProps = (style, props) => {
|
|
10
|
+
let htmlProps = {};
|
|
11
|
+
if (Boolean(props.drag)) {
|
|
12
|
+
// Disable the ghost element when a user drags
|
|
13
|
+
htmlProps.draggable = false;
|
|
14
|
+
|
|
15
|
+
// Disable text selection
|
|
16
|
+
style.userSelect =
|
|
17
|
+
style.WebkitUserSelect =
|
|
18
|
+
style.WebkitTouchCallout =
|
|
19
|
+
"none";
|
|
20
|
+
|
|
21
|
+
// Disable scrolling on the draggable direction
|
|
22
|
+
style.touchAction =
|
|
23
|
+
props.drag === true ? "none" : `pan-${props.drag === "x" ? "y" : "x"}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
htmlProps.style = style;
|
|
27
|
+
return htmlProps;
|
|
28
|
+
};
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<UseStyle let:styles {visualState} {props} {isStatic}>
|
|
32
|
+
<slot visualProps={getHTMLProps(styles, props)} />
|
|
33
|
+
</UseStyle>
|