framer-motion 5.3.2 → 5.4.0-beta.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/es/animation/utils/easing.mjs +1 -1
- package/dist/es/animation/utils/transitions.mjs +1 -1
- package/dist/es/components/AnimatePresence/index.mjs +1 -1
- package/dist/es/components/AnimatePresence/use-presence.mjs +1 -27
- package/dist/es/components/AnimateSharedLayout.mjs +1 -1
- package/dist/es/components/MotionCanvas/index.mjs +14 -0
- package/dist/es/components/Reorder/Item.mjs +1 -1
- package/dist/es/context/MotionContext/index.mjs +1 -1
- package/dist/es/events/use-dom-event.mjs +2 -31
- package/dist/es/events/use-pointer-event.mjs +2 -5
- package/dist/es/gestures/utils/event-type.mjs +1 -8
- package/dist/es/motion/index.mjs +1 -1
- package/dist/es/projection/animation/mix-values.mjs +1 -1
- package/dist/es/projection/geometry/models.mjs +1 -11
- package/dist/es/projection/node/create-projection-node.mjs +4 -1167
- package/dist/es/projection/styles/scale-border-radius.mjs +1 -1
- package/dist/es/projection/styles/transform.mjs +5 -5
- package/dist/es/render/dom/motion-proxy.mjs +3 -0
- package/dist/es/render/dom/utils/css-variables-conversion.mjs +2 -2
- package/dist/es/render/dom/utils/filter-props.mjs +3 -1
- package/dist/es/render/dom/value-types/dimensions.mjs +1 -8
- package/dist/es/render/html/use-props.mjs +1 -1
- package/dist/es/render/html/utils/build-transform.mjs +2 -2
- package/dist/es/render/svg/utils/path.mjs +1 -1
- package/dist/es/render/svg/utils/transform-origin.mjs +1 -1
- package/dist/es/render/three/create-visual-element.mjs +42 -0
- package/dist/es/render/three/gestures/use-hover.mjs +22 -0
- package/dist/es/render/three/gestures/use-tap.mjs +56 -0
- package/dist/es/render/three/motion.mjs +30 -0
- package/dist/es/render/three/use-render.mjs +11 -0
- package/dist/es/render/three/utils/read-value.mjs +43 -0
- package/dist/es/render/three/utils/set-value.mjs +59 -0
- package/dist/es/render/utils/animation.mjs +1 -4
- package/dist/es/render/utils/setters.mjs +2 -39
- package/dist/es/three-entry.mjs +2 -0
- package/dist/es/utils/array.mjs +2 -13
- package/dist/framer-motion-three.cjs.js +3004 -0
- package/dist/framer-motion.cjs.js +46 -43
- package/dist/framer-motion.dev.js +35 -32
- package/dist/framer-motion.js +1 -1
- package/dist/projection.dev.js +17 -17
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/package.json +27 -6
- package/types/components/MotionCanvas/index.d.ts +4 -0
- package/types/motion/features/types.d.ts +1 -1
- package/types/render/three/create-visual-element.d.ts +6 -0
- package/types/render/three/gestures/use-hover.d.ts +10 -0
- package/types/render/three/gestures/use-tap.d.ts +8 -0
- package/types/render/three/motion.d.ts +5 -0
- package/types/render/three/types.d.ts +24 -0
- package/types/render/three/use-render.d.ts +4 -0
- package/types/render/three/utils/read-value.d.ts +2 -0
- package/types/render/three/utils/set-value.d.ts +2 -0
- package/types/render/utils/lifecycles.d.ts +8 -8
- package/types/render/utils/setters.d.ts +1 -0
- package/types/three-entry.d.ts +2 -0
|
@@ -8,17 +8,17 @@ function buildProjectionTransform(delta, treeScale, latestTransform) {
|
|
|
8
8
|
*/
|
|
9
9
|
var xTranslate = delta.x.translate / treeScale.x;
|
|
10
10
|
var yTranslate = delta.y.translate / treeScale.y;
|
|
11
|
-
var transform = "translate3d("
|
|
11
|
+
var transform = "translate3d(".concat(xTranslate, "px, ").concat(yTranslate, "px, 0) ");
|
|
12
12
|
if (latestTransform) {
|
|
13
13
|
var rotate = latestTransform.rotate, rotateX = latestTransform.rotateX, rotateY = latestTransform.rotateY;
|
|
14
14
|
if (rotate)
|
|
15
|
-
transform += "rotate("
|
|
15
|
+
transform += "rotate(".concat(rotate, "deg) ");
|
|
16
16
|
if (rotateX)
|
|
17
|
-
transform += "rotateX("
|
|
17
|
+
transform += "rotateX(".concat(rotateX, "deg) ");
|
|
18
18
|
if (rotateY)
|
|
19
|
-
transform += "rotateY("
|
|
19
|
+
transform += "rotateY(".concat(rotateY, "deg) ");
|
|
20
20
|
}
|
|
21
|
-
transform += "scale("
|
|
21
|
+
transform += "scale(".concat(delta.x.scale, ", ").concat(delta.y.scale, ")");
|
|
22
22
|
return transform === identityProjection ? "none" : transform;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -19,6 +19,9 @@ function createMotionProxy(createConfig) {
|
|
|
19
19
|
if (customMotionComponentConfig === void 0) { customMotionComponentConfig = {}; }
|
|
20
20
|
return createMotionComponent(createConfig(Component, customMotionComponentConfig));
|
|
21
21
|
}
|
|
22
|
+
if (typeof Proxy === "undefined") {
|
|
23
|
+
return custom;
|
|
24
|
+
}
|
|
22
25
|
/**
|
|
23
26
|
* A cache of generated `motion` components, e.g `motion.div`, `motion.input` etc.
|
|
24
27
|
* Rather than generating them anew every render.
|
|
@@ -24,7 +24,7 @@ function parseCSSVariable(current) {
|
|
|
24
24
|
var maxDepth = 4;
|
|
25
25
|
function getVariableValue(current, element, depth) {
|
|
26
26
|
if (depth === void 0) { depth = 1; }
|
|
27
|
-
invariant(depth <= maxDepth, "Max CSS variable fallback depth detected in property \""
|
|
27
|
+
invariant(depth <= maxDepth, "Max CSS variable fallback depth detected in property \"".concat(current, "\". This may indicate a circular fallback dependency."));
|
|
28
28
|
var _a = __read(parseCSSVariable(current), 2), token = _a[0], fallback = _a[1];
|
|
29
29
|
// No CSS variable detected
|
|
30
30
|
if (!token)
|
|
@@ -51,7 +51,7 @@ function resolveCSSVariables(visualElement, _a, transitionEnd) {
|
|
|
51
51
|
var _b;
|
|
52
52
|
var target = __rest(_a, []);
|
|
53
53
|
var element = visualElement.getInstance();
|
|
54
|
-
if (!(element instanceof
|
|
54
|
+
if (!(element instanceof Element))
|
|
55
55
|
return { target: target, transitionEnd: transitionEnd };
|
|
56
56
|
// If `transitionEnd` isn't `undefined`, clone it. We could clone `target` and `transitionEnd`
|
|
57
57
|
// only if they change but I think this reads clearer and this isn't a performance-critical path.
|
|
@@ -34,7 +34,9 @@ function filterProps(props, isDom, forwardMotionProps) {
|
|
|
34
34
|
for (var key in props) {
|
|
35
35
|
if (shouldForward(key) ||
|
|
36
36
|
(forwardMotionProps === true && isValidMotionProp(key)) ||
|
|
37
|
-
(!isDom && !isValidMotionProp(key))
|
|
37
|
+
(!isDom && !isValidMotionProp(key)) ||
|
|
38
|
+
// If trying to use native HTML drag events, forward drag listeners
|
|
39
|
+
(props["draggable"] && key.startsWith("onDrag"))) {
|
|
38
40
|
filteredProps[key] = props[key];
|
|
39
41
|
}
|
|
40
42
|
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { number, px, percent, degrees, vw, vh } from 'style-value-types';
|
|
2
|
-
import { testValueType } from './test.mjs';
|
|
3
2
|
import { auto } from './type-auto.mjs';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* A list of value types commonly used for dimensions
|
|
7
6
|
*/
|
|
8
7
|
var dimensionValueTypes = [number, px, percent, degrees, vw, vh, auto];
|
|
9
|
-
/**
|
|
10
|
-
* Tests a dimensional value against the list of dimension ValueTypes
|
|
11
|
-
*/
|
|
12
|
-
var findDimensionValueType = function (v) {
|
|
13
|
-
return dimensionValueTypes.find(testValueType(v));
|
|
14
|
-
};
|
|
15
8
|
|
|
16
|
-
export { dimensionValueTypes
|
|
9
|
+
export { dimensionValueTypes };
|
|
@@ -50,7 +50,7 @@ function useHTMLProps(props, visualState, isStatic) {
|
|
|
50
50
|
style.touchAction =
|
|
51
51
|
props.drag === true
|
|
52
52
|
? "none"
|
|
53
|
-
: "pan-"
|
|
53
|
+
: "pan-".concat(props.drag === "x" ? "y" : "x");
|
|
54
54
|
}
|
|
55
55
|
htmlProps.style = style;
|
|
56
56
|
return htmlProps;
|
|
@@ -26,7 +26,7 @@ function buildTransform(_a, _b, transformIsDefault, transformTemplate) {
|
|
|
26
26
|
var numTransformKeys = transformKeys.length;
|
|
27
27
|
for (var i = 0; i < numTransformKeys; i++) {
|
|
28
28
|
var key = transformKeys[i];
|
|
29
|
-
transformString += (translateAlias[key] || key
|
|
29
|
+
transformString += "".concat(translateAlias[key] || key, "(").concat(transform[key], ") ");
|
|
30
30
|
if (key === "z")
|
|
31
31
|
transformHasZ = true;
|
|
32
32
|
}
|
|
@@ -52,7 +52,7 @@ function buildTransform(_a, _b, transformIsDefault, transformTemplate) {
|
|
|
52
52
|
*/
|
|
53
53
|
function buildTransformOrigin(_a) {
|
|
54
54
|
var _b = _a.originX, originX = _b === void 0 ? "50%" : _b, _c = _a.originY, originY = _c === void 0 ? "50%" : _c, _d = _a.originZ, originZ = _d === void 0 ? 0 : _d;
|
|
55
|
-
return originX
|
|
55
|
+
return "".concat(originX, " ").concat(originY, " ").concat(originZ);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export { buildTransform, buildTransformOrigin };
|
|
@@ -29,7 +29,7 @@ function buildSVGPath(attrs, length, spacing, offset, useDashCase) {
|
|
|
29
29
|
// Build the dash array
|
|
30
30
|
var pathLength = px.transform(length);
|
|
31
31
|
var pathSpacing = px.transform(spacing);
|
|
32
|
-
attrs[keys.array] = pathLength
|
|
32
|
+
attrs[keys.array] = "".concat(pathLength, " ").concat(pathSpacing);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export { buildSVGPath };
|
|
@@ -12,7 +12,7 @@ function calcOrigin(origin, offset, size) {
|
|
|
12
12
|
function calcSVGTransformOrigin(dimensions, originX, originY) {
|
|
13
13
|
var pxOriginX = calcOrigin(originX, dimensions.x, dimensions.width);
|
|
14
14
|
var pxOriginY = calcOrigin(originY, dimensions.y, dimensions.height);
|
|
15
|
-
return pxOriginX
|
|
15
|
+
return "".concat(pxOriginX, " ").concat(pxOriginY);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export { calcSVGTransformOrigin };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { visualElement } from '../index.mjs';
|
|
2
|
+
import { createBox } from '../../projection/geometry/models.mjs';
|
|
3
|
+
import { checkTargetForNewValues } from '../utils/setters.mjs';
|
|
4
|
+
import { setThreeValue } from './utils/set-value.mjs';
|
|
5
|
+
import { readThreeValue } from './utils/read-value.mjs';
|
|
6
|
+
|
|
7
|
+
var scrapeMotionValuesFromProps = function () { return ({}); };
|
|
8
|
+
var createRenderState = function () { return ({}); };
|
|
9
|
+
var threeVisualElement = visualElement({
|
|
10
|
+
treeType: "three",
|
|
11
|
+
readValueFromInstance: readThreeValue,
|
|
12
|
+
getBaseTarget: function (_props, _key) {
|
|
13
|
+
return 0;
|
|
14
|
+
},
|
|
15
|
+
sortNodePosition: function (_a, _b) {
|
|
16
|
+
return 0;
|
|
17
|
+
},
|
|
18
|
+
makeTargetAnimatable: function (element, target) {
|
|
19
|
+
checkTargetForNewValues(element, target, {});
|
|
20
|
+
return target;
|
|
21
|
+
},
|
|
22
|
+
restoreTransform: function () { },
|
|
23
|
+
resetTransform: function () { },
|
|
24
|
+
removeValueFromRenderState: function (_key, _renderState) { },
|
|
25
|
+
measureViewportBox: createBox,
|
|
26
|
+
scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
|
|
27
|
+
build: function (_element, state, latestValues) {
|
|
28
|
+
for (var key in latestValues) {
|
|
29
|
+
state[key] = latestValues[key];
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
render: function (instance, renderState) {
|
|
33
|
+
for (var key in renderState) {
|
|
34
|
+
setThreeValue(instance, key, renderState);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
var createVisualElement = function (_, options) {
|
|
39
|
+
return threeVisualElement(options);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export { createRenderState, createVisualElement, scrapeMotionValuesFromProps, threeVisualElement };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AnimationType } from '../../utils/types.mjs';
|
|
2
|
+
|
|
3
|
+
function useHover(isStatic, _a, visualElement) {
|
|
4
|
+
var whileHover = _a.whileHover, onHoverStart = _a.onHoverStart, onHoverEnd = _a.onHoverEnd, onPointerOver = _a.onPointerOver, onPointerOut = _a.onPointerOut;
|
|
5
|
+
var isHoverEnabled = whileHover || onHoverStart || onHoverEnd;
|
|
6
|
+
if (isStatic || !visualElement || !isHoverEnabled)
|
|
7
|
+
return {};
|
|
8
|
+
return {
|
|
9
|
+
onPointerOver: function (event) {
|
|
10
|
+
var _a;
|
|
11
|
+
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Hover, true);
|
|
12
|
+
onPointerOver === null || onPointerOver === void 0 ? void 0 : onPointerOver(event);
|
|
13
|
+
},
|
|
14
|
+
onPointerOut: function (event) {
|
|
15
|
+
var _a;
|
|
16
|
+
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Hover, false);
|
|
17
|
+
onPointerOut === null || onPointerOut === void 0 ? void 0 : onPointerOut(event);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { useHover };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { pipe } from 'popmotion';
|
|
2
|
+
import { useRef } from 'react';
|
|
3
|
+
import { wrapHandler } from '../../../events/event-info.mjs';
|
|
4
|
+
import { addPointerEvent } from '../../../events/use-pointer-event.mjs';
|
|
5
|
+
import { isDragActive } from '../../../gestures/drag/utils/lock.mjs';
|
|
6
|
+
import { AnimationType } from '../../utils/types.mjs';
|
|
7
|
+
|
|
8
|
+
function useTap(isStatic, _a, visualElement) {
|
|
9
|
+
var whileTap = _a.whileTap, onTapStart = _a.onTapStart, onTap = _a.onTap, onTapCancel = _a.onTapCancel, onPointerDown = _a.onPointerDown;
|
|
10
|
+
var isTapEnabled = onTap || onTapStart || onTapCancel || whileTap;
|
|
11
|
+
var isPressing = useRef(false);
|
|
12
|
+
var cancelPointerEndListeners = useRef(null);
|
|
13
|
+
if (isStatic || !visualElement || !isTapEnabled)
|
|
14
|
+
return {};
|
|
15
|
+
function removePointerEndListener() {
|
|
16
|
+
var _a;
|
|
17
|
+
(_a = cancelPointerEndListeners.current) === null || _a === void 0 ? void 0 : _a.call(cancelPointerEndListeners);
|
|
18
|
+
cancelPointerEndListeners.current = null;
|
|
19
|
+
}
|
|
20
|
+
function checkPointerEnd() {
|
|
21
|
+
var _a;
|
|
22
|
+
removePointerEndListener();
|
|
23
|
+
isPressing.current = false;
|
|
24
|
+
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Tap, false);
|
|
25
|
+
return !isDragActive();
|
|
26
|
+
}
|
|
27
|
+
function onPointerUp(event, info) {
|
|
28
|
+
if (!checkPointerEnd())
|
|
29
|
+
return;
|
|
30
|
+
/**
|
|
31
|
+
* We only count this as a tap gesture if the event.target is the same
|
|
32
|
+
* as, or a child of, this component's element
|
|
33
|
+
*/
|
|
34
|
+
onTap === null || onTap === void 0 ? void 0 : onTap(event, info);
|
|
35
|
+
}
|
|
36
|
+
function onPointerCancel(event, info) {
|
|
37
|
+
if (!checkPointerEnd())
|
|
38
|
+
return;
|
|
39
|
+
onTapCancel === null || onTapCancel === void 0 ? void 0 : onTapCancel(event, info);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
onPointerDown: wrapHandler(function (event, info) {
|
|
43
|
+
var _a;
|
|
44
|
+
removePointerEndListener();
|
|
45
|
+
if (isPressing.current)
|
|
46
|
+
return;
|
|
47
|
+
isPressing.current = true;
|
|
48
|
+
cancelPointerEndListeners.current = pipe(addPointerEvent(window, "pointerup", onPointerUp), addPointerEvent(window, "pointercancel", onPointerCancel));
|
|
49
|
+
(_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.setActive(AnimationType.Tap, true);
|
|
50
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
51
|
+
onTapStart === null || onTapStart === void 0 ? void 0 : onTapStart(event, info);
|
|
52
|
+
}, true),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { useTap };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __assign } from 'tslib';
|
|
2
|
+
import { createMotionComponent } from '../../motion/index.mjs';
|
|
3
|
+
import { animations } from '../../motion/features/animations.mjs';
|
|
4
|
+
import { makeUseVisualState } from '../../motion/utils/use-visual-state.mjs';
|
|
5
|
+
import { useRender } from './use-render.mjs';
|
|
6
|
+
import { scrapeMotionValuesFromProps, createRenderState, createVisualElement } from './create-visual-element.mjs';
|
|
7
|
+
|
|
8
|
+
var useVisualState = makeUseVisualState({
|
|
9
|
+
scrapeMotionValuesFromProps: scrapeMotionValuesFromProps,
|
|
10
|
+
createRenderState: createRenderState,
|
|
11
|
+
});
|
|
12
|
+
var preloadedFeatures = __assign({}, animations);
|
|
13
|
+
function custom(Component) {
|
|
14
|
+
return createMotionComponent({
|
|
15
|
+
Component: Component,
|
|
16
|
+
preloadedFeatures: preloadedFeatures,
|
|
17
|
+
useRender: useRender,
|
|
18
|
+
useVisualState: useVisualState,
|
|
19
|
+
createVisualElement: createVisualElement,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
var componentCache = new Map();
|
|
23
|
+
var motion = new Proxy(custom, {
|
|
24
|
+
get: function (_, key) {
|
|
25
|
+
!componentCache.has(key) && componentCache.set(key, custom(key));
|
|
26
|
+
return componentCache.get(key);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export { motion };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __assign } from 'tslib';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { filterProps } from '../dom/utils/filter-props.mjs';
|
|
4
|
+
import { useHover } from './gestures/use-hover.mjs';
|
|
5
|
+
import { useTap } from './gestures/use-tap.mjs';
|
|
6
|
+
|
|
7
|
+
var useRender = function (Component, props, _projectionId, ref, _state, isStatic, visualElement) {
|
|
8
|
+
return createElement(Component, __assign(__assign(__assign(__assign({ ref: ref }, filterProps(props, false, false)), { onUpdate: props.onInstanceUpdate }), useHover(isStatic, props, visualElement)), useTap(isStatic, props, visualElement)));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { useRender };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Color } from 'three';
|
|
2
|
+
|
|
3
|
+
var readVector = function (name, defaultValue) {
|
|
4
|
+
return function (axis) {
|
|
5
|
+
return function (instance) {
|
|
6
|
+
var value = instance[name];
|
|
7
|
+
return value ? value[axis] : defaultValue;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
var readPosition = readVector("position", 0);
|
|
12
|
+
var readScale = readVector("scale", 1);
|
|
13
|
+
var readRotation = readVector("rotation", 0);
|
|
14
|
+
var readers = {
|
|
15
|
+
x: readPosition("x"),
|
|
16
|
+
y: readPosition("y"),
|
|
17
|
+
z: readPosition("z"),
|
|
18
|
+
scale: readScale("x"),
|
|
19
|
+
scaleX: readScale("x"),
|
|
20
|
+
scaleY: readScale("y"),
|
|
21
|
+
scaleZ: readScale("z"),
|
|
22
|
+
rotateX: readRotation("x"),
|
|
23
|
+
rotateY: readRotation("y"),
|
|
24
|
+
rotateZ: readRotation("z"),
|
|
25
|
+
};
|
|
26
|
+
function readAnimatableValue(value) {
|
|
27
|
+
if (!value)
|
|
28
|
+
return;
|
|
29
|
+
if (value instanceof Color) {
|
|
30
|
+
return value.getStyle();
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function readThreeValue(instance, name) {
|
|
37
|
+
var _a;
|
|
38
|
+
return readers[name]
|
|
39
|
+
? readers[name](instance)
|
|
40
|
+
: (_a = readAnimatableValue(instance[name])) !== null && _a !== void 0 ? _a : 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { readThreeValue };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Vector3, Euler, Color } from 'three';
|
|
2
|
+
|
|
3
|
+
var setVector = function (name, defaultValue) {
|
|
4
|
+
return function (i) {
|
|
5
|
+
return function (instance, value) {
|
|
6
|
+
var _a;
|
|
7
|
+
(_a = instance[name]) !== null && _a !== void 0 ? _a : (instance[name] = new Vector3(defaultValue));
|
|
8
|
+
var vector = instance[name];
|
|
9
|
+
vector.setComponent(i, value);
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
var setEuler = function (name, defaultValue) {
|
|
14
|
+
return function (axis) {
|
|
15
|
+
return function (instance, value) {
|
|
16
|
+
var _a;
|
|
17
|
+
(_a = instance[name]) !== null && _a !== void 0 ? _a : (instance[name] = new Euler(defaultValue));
|
|
18
|
+
var euler = instance[name];
|
|
19
|
+
euler[axis] = value;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
var setColor = function (name) { return function (instance, value) {
|
|
24
|
+
var _a;
|
|
25
|
+
(_a = instance[name]) !== null && _a !== void 0 ? _a : (instance[name] = new Color(value));
|
|
26
|
+
instance[name].set(value);
|
|
27
|
+
}; };
|
|
28
|
+
var setScale = setVector("scale", 1);
|
|
29
|
+
var setPosition = setVector("position", 0);
|
|
30
|
+
var setRotation = setEuler("rotation", 0);
|
|
31
|
+
var setters = {
|
|
32
|
+
x: setPosition(0),
|
|
33
|
+
y: setPosition(1),
|
|
34
|
+
z: setPosition(2),
|
|
35
|
+
scale: function (instance, value) {
|
|
36
|
+
var _a;
|
|
37
|
+
(_a = instance.scale) !== null && _a !== void 0 ? _a : (instance.scale = new Vector3(1));
|
|
38
|
+
var scale = instance.scale;
|
|
39
|
+
scale.set(value, value, value);
|
|
40
|
+
},
|
|
41
|
+
scaleX: setScale(0),
|
|
42
|
+
scaleY: setScale(1),
|
|
43
|
+
scaleZ: setScale(2),
|
|
44
|
+
rotateX: setRotation("x"),
|
|
45
|
+
rotateY: setRotation("y"),
|
|
46
|
+
rotateZ: setRotation("z"),
|
|
47
|
+
color: setColor("color"),
|
|
48
|
+
specular: setColor("specular"),
|
|
49
|
+
};
|
|
50
|
+
function setThreeValue(instance, key, values) {
|
|
51
|
+
if (setters[key]) {
|
|
52
|
+
setters[key](instance, values[key]);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
instance[key] = values[key];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { setThreeValue };
|
|
@@ -119,9 +119,6 @@ function animateChildren(visualElement, variant, delayChildren, staggerChildren,
|
|
|
119
119
|
});
|
|
120
120
|
return Promise.all(animations);
|
|
121
121
|
}
|
|
122
|
-
function stopAnimation(visualElement) {
|
|
123
|
-
visualElement.forEachValue(function (value) { return value.stop(); });
|
|
124
|
-
}
|
|
125
122
|
function sortByTreeOrder(a, b) {
|
|
126
123
|
return a.sortNodePosition(b);
|
|
127
124
|
}
|
|
@@ -138,4 +135,4 @@ function shouldBlockAnimation(_a, key) {
|
|
|
138
135
|
return shouldBlock;
|
|
139
136
|
}
|
|
140
137
|
|
|
141
|
-
export { animateVisualElement, sortByTreeOrder
|
|
138
|
+
export { animateVisualElement, sortByTreeOrder };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __rest, __assign
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
2
|
import { complex } from 'style-value-types';
|
|
3
3
|
import { isNumericalString } from '../../utils/is-numerical-string.mjs';
|
|
4
4
|
import { isZeroValueString } from '../../utils/is-zero-value-string.mjs';
|
|
@@ -29,28 +29,6 @@ function setTarget(visualElement, definition) {
|
|
|
29
29
|
setMotionValue(visualElement, key, value);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
function setVariants(visualElement, variantLabels) {
|
|
33
|
-
var reversedLabels = __spreadArray([], __read(variantLabels), false).reverse();
|
|
34
|
-
reversedLabels.forEach(function (key) {
|
|
35
|
-
var _a;
|
|
36
|
-
var variant = visualElement.getVariant(key);
|
|
37
|
-
variant && setTarget(visualElement, variant);
|
|
38
|
-
(_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
|
|
39
|
-
setVariants(child, variantLabels);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function setValues(visualElement, definition) {
|
|
44
|
-
if (Array.isArray(definition)) {
|
|
45
|
-
return setVariants(visualElement, definition);
|
|
46
|
-
}
|
|
47
|
-
else if (typeof definition === "string") {
|
|
48
|
-
return setVariants(visualElement, [definition]);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
setTarget(visualElement, definition);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
32
|
function checkTargetForNewValues(visualElement, target, origin) {
|
|
55
33
|
var _a, _b, _c;
|
|
56
34
|
var _d;
|
|
@@ -96,20 +74,5 @@ function checkTargetForNewValues(visualElement, target, origin) {
|
|
|
96
74
|
visualElement.setBaseTarget(key, value);
|
|
97
75
|
}
|
|
98
76
|
}
|
|
99
|
-
function getOriginFromTransition(key, transition) {
|
|
100
|
-
if (!transition)
|
|
101
|
-
return;
|
|
102
|
-
var valueTransition = transition[key] || transition["default"] || transition;
|
|
103
|
-
return valueTransition.from;
|
|
104
|
-
}
|
|
105
|
-
function getOrigin(target, transition, visualElement) {
|
|
106
|
-
var _a, _b;
|
|
107
|
-
var origin = {};
|
|
108
|
-
for (var key in target) {
|
|
109
|
-
origin[key] =
|
|
110
|
-
(_a = getOriginFromTransition(key, transition)) !== null && _a !== void 0 ? _a : (_b = visualElement.getValue(key)) === null || _b === void 0 ? void 0 : _b.get();
|
|
111
|
-
}
|
|
112
|
-
return origin;
|
|
113
|
-
}
|
|
114
77
|
|
|
115
|
-
export { checkTargetForNewValues,
|
|
78
|
+
export { checkTargetForNewValues, setTarget };
|
package/dist/es/utils/array.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'tslib';
|
|
2
2
|
|
|
3
3
|
function addUniqueItem(arr, item) {
|
|
4
4
|
arr.indexOf(item) === -1 && arr.push(item);
|
|
@@ -7,16 +7,5 @@ function removeItem(arr, item) {
|
|
|
7
7
|
var index = arr.indexOf(item);
|
|
8
8
|
index > -1 && arr.splice(index, 1);
|
|
9
9
|
}
|
|
10
|
-
// Adapted from array-move
|
|
11
|
-
function moveItem(_a, fromIndex, toIndex) {
|
|
12
|
-
var _b = __read(_a), arr = _b.slice(0);
|
|
13
|
-
var startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;
|
|
14
|
-
if (startIndex >= 0 && startIndex < arr.length) {
|
|
15
|
-
var endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;
|
|
16
|
-
var _c = __read(arr.splice(fromIndex, 1), 1), item = _c[0];
|
|
17
|
-
arr.splice(endIndex, 0, item);
|
|
18
|
-
}
|
|
19
|
-
return arr;
|
|
20
|
-
}
|
|
21
10
|
|
|
22
|
-
export { addUniqueItem,
|
|
11
|
+
export { addUniqueItem, removeItem };
|