framer-motion 9.1.0 → 9.1.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/README.md +15 -15
- package/dist/cjs/index.js +605 -116
- package/dist/es/animation/hooks/animation-controls.mjs +1 -1
- package/dist/es/animation/index.mjs +1 -1
- package/dist/es/animation/legacy-popmotion/find-spring.mjs +1 -1
- package/dist/es/animation/legacy-popmotion/keyframes.mjs +3 -8
- package/dist/es/animation/utils/easing.mjs +1 -1
- package/dist/es/components/AnimateSharedLayout.mjs +2 -2
- package/dist/es/components/Reorder/Group.mjs +1 -1
- package/dist/es/components/Reorder/Item.mjs +1 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +3 -4
- package/dist/es/gestures/focus.mjs +2 -3
- package/dist/es/gestures/hover.mjs +1 -2
- package/dist/es/gestures/press.mjs +2 -3
- package/dist/es/index.mjs +1 -0
- package/dist/es/motion/features/animation/exit.mjs +1 -2
- package/dist/es/motion/features/viewport/index.mjs +2 -3
- package/dist/es/render/VisualElement.mjs +3 -4
- package/dist/es/render/dom/resize/handle-element.mjs +64 -0
- package/dist/es/render/dom/resize/handle-window.mjs +30 -0
- package/dist/es/render/dom/resize/index.mjs +8 -0
- package/dist/es/render/dom/scroll/index.mjs +74 -0
- package/dist/es/render/dom/scroll/info.mjs +56 -0
- package/dist/es/render/dom/scroll/offsets/edge.mjs +45 -0
- package/dist/es/render/dom/scroll/offsets/index.mjs +54 -0
- package/dist/es/render/dom/scroll/offsets/inset.mjs +25 -0
- package/dist/es/render/dom/scroll/offsets/offset.mjs +35 -0
- package/dist/es/render/dom/scroll/offsets/presets.mjs +20 -0
- package/dist/es/render/dom/scroll/on-scroll-handler.mjs +38 -0
- package/dist/es/render/dom/utils/css-variables-conversion.mjs +5 -7
- package/dist/es/render/dom/utils/is-css-variable.mjs +4 -7
- package/dist/es/render/dom/utils/resolve-element.mjs +21 -0
- package/dist/es/render/dom/utils/unit-conversion.mjs +2 -11
- package/dist/es/render/dom/viewport/index.mjs +52 -0
- package/dist/es/render/html/HTMLVisualElement.mjs +2 -2
- package/dist/es/render/html/utils/build-styles.mjs +2 -2
- package/dist/es/render/utils/animation-state.mjs +16 -21
- package/dist/es/render/utils/is-controlling-variants.mjs +1 -10
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/render/utils/variant-props.mjs +12 -0
- package/dist/es/utils/errors.mjs +18 -0
- package/dist/es/utils/interpolate.mjs +1 -1
- package/dist/es/utils/mix-color.mjs +1 -1
- package/dist/es/utils/mix-complex.mjs +1 -1
- package/dist/es/utils/offsets/default.mjs +9 -0
- package/dist/es/utils/offsets/fill.mjs +12 -0
- package/dist/es/utils/offsets/time.mjs +5 -0
- package/dist/es/utils/use-in-view.mjs +1 -1
- package/dist/es/value/index.mjs +1 -1
- package/dist/es/value/use-inverted-scale.mjs +1 -1
- package/dist/es/value/use-scroll.mjs +2 -2
- package/dist/es/value/use-will-change/index.mjs +2 -2
- package/dist/framer-motion.dev.js +238 -370
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +12 -3
- package/dist/projection.dev.js +53 -78
- package/dist/size-rollup-dom-animation-assets.js +1 -1
- package/dist/size-rollup-dom-animation.js +1 -1
- package/dist/size-rollup-dom-max-assets.js +1 -1
- package/dist/size-rollup-dom-max.js +1 -1
- package/dist/size-rollup-m.js +1 -1
- package/dist/size-rollup-motion.js +1 -1
- package/dist/size-webpack-dom-animation.js +1 -1
- package/dist/size-webpack-dom-max.js +1 -1
- package/dist/size-webpack-m.js +1 -1
- package/dist/three-entry.d.ts +1 -1
- package/package.json +9 -11
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { namedEdges, resolveEdge } from './edge.mjs';
|
|
2
|
+
|
|
3
|
+
const defaultOffset = [0, 0];
|
|
4
|
+
function resolveOffset(offset, containerLength, targetLength, targetInset) {
|
|
5
|
+
let offsetDefinition = Array.isArray(offset) ? offset : defaultOffset;
|
|
6
|
+
let targetPoint = 0;
|
|
7
|
+
let containerPoint = 0;
|
|
8
|
+
if (typeof offset === "number") {
|
|
9
|
+
/**
|
|
10
|
+
* If we're provided offset: [0, 0.5, 1] then each number x should become
|
|
11
|
+
* [x, x], so we default to the behaviour of mapping 0 => 0 of both target
|
|
12
|
+
* and container etc.
|
|
13
|
+
*/
|
|
14
|
+
offsetDefinition = [offset, offset];
|
|
15
|
+
}
|
|
16
|
+
else if (typeof offset === "string") {
|
|
17
|
+
offset = offset.trim();
|
|
18
|
+
if (offset.includes(" ")) {
|
|
19
|
+
offsetDefinition = offset.split(" ");
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
/**
|
|
23
|
+
* If we're provided a definition like "100px" then we want to apply
|
|
24
|
+
* that only to the top of the target point, leaving the container at 0.
|
|
25
|
+
* Whereas a named offset like "end" should be applied to both.
|
|
26
|
+
*/
|
|
27
|
+
offsetDefinition = [offset, namedEdges[offset] ? offset : `0`];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
targetPoint = resolveEdge(offsetDefinition[0], targetLength, targetInset);
|
|
31
|
+
containerPoint = resolveEdge(offsetDefinition[1], containerLength);
|
|
32
|
+
return targetPoint - containerPoint;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { resolveOffset };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { updateScrollInfo } from './info.mjs';
|
|
2
|
+
import { resolveOffsets } from './offsets/index.mjs';
|
|
3
|
+
|
|
4
|
+
function measure(container, target = container, info) {
|
|
5
|
+
/**
|
|
6
|
+
* Find inset of target within scrollable container
|
|
7
|
+
*/
|
|
8
|
+
info.x.targetOffset = 0;
|
|
9
|
+
info.y.targetOffset = 0;
|
|
10
|
+
if (target !== container) {
|
|
11
|
+
let node = target;
|
|
12
|
+
while (node && node !== container) {
|
|
13
|
+
info.x.targetOffset += node.offsetLeft;
|
|
14
|
+
info.y.targetOffset += node.offsetTop;
|
|
15
|
+
node = node.offsetParent;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
info.x.targetLength =
|
|
19
|
+
target === container ? target.scrollWidth : target.clientWidth;
|
|
20
|
+
info.y.targetLength =
|
|
21
|
+
target === container ? target.scrollHeight : target.clientHeight;
|
|
22
|
+
info.x.containerLength = container.clientWidth;
|
|
23
|
+
info.y.containerLength = container.clientHeight;
|
|
24
|
+
}
|
|
25
|
+
function createOnScrollHandler(element, onScroll, info, options = {}) {
|
|
26
|
+
return {
|
|
27
|
+
measure: () => measure(element, options.target, info),
|
|
28
|
+
update: (time) => {
|
|
29
|
+
updateScrollInfo(element, info, time);
|
|
30
|
+
if (options.offset || options.target) {
|
|
31
|
+
resolveOffsets(element, info, options);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
notify: () => onScroll(info),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { createOnScrollHandler };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { invariant } from '
|
|
1
|
+
import { invariant } from '../../../utils/errors.mjs';
|
|
2
|
+
import { isCSSVariableToken } from './is-css-variable.mjs';
|
|
2
3
|
|
|
3
|
-
function isCSSVariable(value) {
|
|
4
|
-
return typeof value === "string" && value.startsWith("var(--");
|
|
5
|
-
}
|
|
6
4
|
/**
|
|
7
5
|
* Parse Framer's special CSS variable format into a CSS token and a fallback.
|
|
8
6
|
*
|
|
@@ -32,7 +30,7 @@ function getVariableValue(current, element, depth = 1) {
|
|
|
32
30
|
if (resolved) {
|
|
33
31
|
return resolved.trim();
|
|
34
32
|
}
|
|
35
|
-
else if (
|
|
33
|
+
else if (isCSSVariableToken(fallback)) {
|
|
36
34
|
// The fallback might itself be a CSS variable, in which case we attempt to resolve it too.
|
|
37
35
|
return getVariableValue(fallback, element, depth + 1);
|
|
38
36
|
}
|
|
@@ -57,7 +55,7 @@ function resolveCSSVariables(visualElement, { ...target }, transitionEnd) {
|
|
|
57
55
|
// Go through existing `MotionValue`s and ensure any existing CSS variables are resolved
|
|
58
56
|
visualElement.values.forEach((value) => {
|
|
59
57
|
const current = value.get();
|
|
60
|
-
if (!
|
|
58
|
+
if (!isCSSVariableToken(current))
|
|
61
59
|
return;
|
|
62
60
|
const resolved = getVariableValue(current, element);
|
|
63
61
|
if (resolved)
|
|
@@ -67,7 +65,7 @@ function resolveCSSVariables(visualElement, { ...target }, transitionEnd) {
|
|
|
67
65
|
// we only read single-var properties like `var(--foo)`, not `calc(var(--foo) + 20px)`
|
|
68
66
|
for (const key in target) {
|
|
69
67
|
const current = target[key];
|
|
70
|
-
if (!
|
|
68
|
+
if (!isCSSVariableToken(current))
|
|
71
69
|
continue;
|
|
72
70
|
const resolved = getVariableValue(current, element);
|
|
73
71
|
if (!resolved)
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function isCSSVariable(key) {
|
|
5
|
-
return key.startsWith("--");
|
|
6
|
-
}
|
|
1
|
+
const checkStringStartsWith = (token) => (key) => typeof key === "string" && key.startsWith(token);
|
|
2
|
+
const isCSSVariableName = checkStringStartsWith("--");
|
|
3
|
+
const isCSSVariableToken = checkStringStartsWith("var(--");
|
|
7
4
|
|
|
8
|
-
export {
|
|
5
|
+
export { isCSSVariableName, isCSSVariableToken };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function resolveElements(elements, selectorCache) {
|
|
2
|
+
var _a;
|
|
3
|
+
if (typeof elements === "string") {
|
|
4
|
+
if (selectorCache) {
|
|
5
|
+
(_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : (selectorCache[elements] = document.querySelectorAll(elements));
|
|
6
|
+
elements = selectorCache[elements];
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
elements = document.querySelectorAll(elements);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
else if (elements instanceof Element) {
|
|
13
|
+
elements = [elements];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Return an empty array
|
|
17
|
+
*/
|
|
18
|
+
return Array.from(elements || []);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { resolveElements };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isKeyframesTarget } from '../../../animation/utils/is-keyframes-target.mjs';
|
|
2
|
-
import { invariant } from '
|
|
2
|
+
import { invariant } from '../../../utils/errors.mjs';
|
|
3
3
|
import { transformPropOrder } from '../../html/utils/transform.mjs';
|
|
4
4
|
import { findDimensionValueType } from '../value-types/dimensions.mjs';
|
|
5
5
|
import { isBrowser } from '../../../utils/is-browser.mjs';
|
|
@@ -21,15 +21,6 @@ const hasPositionalKey = (target) => {
|
|
|
21
21
|
return Object.keys(target).some(isPositionalKey);
|
|
22
22
|
};
|
|
23
23
|
const isNumOrPxType = (v) => v === number || v === px;
|
|
24
|
-
var BoundingBoxDimension;
|
|
25
|
-
(function (BoundingBoxDimension) {
|
|
26
|
-
BoundingBoxDimension["width"] = "width";
|
|
27
|
-
BoundingBoxDimension["height"] = "height";
|
|
28
|
-
BoundingBoxDimension["left"] = "left";
|
|
29
|
-
BoundingBoxDimension["right"] = "right";
|
|
30
|
-
BoundingBoxDimension["top"] = "top";
|
|
31
|
-
BoundingBoxDimension["bottom"] = "bottom";
|
|
32
|
-
})(BoundingBoxDimension || (BoundingBoxDimension = {}));
|
|
33
24
|
const getPosFromMatrix = (matrix, pos) => parseFloat(matrix.split(", ")[pos]);
|
|
34
25
|
const getTranslateFromMatrix = (pos2, pos3) => (_bbox, { transform }) => {
|
|
35
26
|
if (transform === "none" || !transform)
|
|
@@ -225,4 +216,4 @@ function unitConversion(visualElement, target, origin, transitionEnd) {
|
|
|
225
216
|
: { target, transitionEnd };
|
|
226
217
|
}
|
|
227
218
|
|
|
228
|
-
export {
|
|
219
|
+
export { positionalValues, unitConversion };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { resolveElements } from '../utils/resolve-element.mjs';
|
|
2
|
+
|
|
3
|
+
const thresholds = {
|
|
4
|
+
any: 0,
|
|
5
|
+
all: 1,
|
|
6
|
+
};
|
|
7
|
+
function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = "any" } = {}) {
|
|
8
|
+
/**
|
|
9
|
+
* If this browser doesn't support IntersectionObserver, return a dummy stop function.
|
|
10
|
+
* Default triggering of onStart is tricky - it could be used for starting/stopping
|
|
11
|
+
* videos, lazy loading content etc. We could provide an option to enable a fallback, or
|
|
12
|
+
* provide a fallback callback option.
|
|
13
|
+
*/
|
|
14
|
+
if (typeof IntersectionObserver === "undefined") {
|
|
15
|
+
return () => { };
|
|
16
|
+
}
|
|
17
|
+
const elements = resolveElements(elementOrSelector);
|
|
18
|
+
const activeIntersections = new WeakMap();
|
|
19
|
+
const onIntersectionChange = (entries) => {
|
|
20
|
+
entries.forEach((entry) => {
|
|
21
|
+
const onEnd = activeIntersections.get(entry.target);
|
|
22
|
+
/**
|
|
23
|
+
* If there's no change to the intersection, we don't need to
|
|
24
|
+
* do anything here.
|
|
25
|
+
*/
|
|
26
|
+
if (entry.isIntersecting === Boolean(onEnd))
|
|
27
|
+
return;
|
|
28
|
+
if (entry.isIntersecting) {
|
|
29
|
+
const newOnEnd = onStart(entry);
|
|
30
|
+
if (typeof newOnEnd === "function") {
|
|
31
|
+
activeIntersections.set(entry.target, newOnEnd);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
observer.unobserve(entry.target);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else if (onEnd) {
|
|
38
|
+
onEnd(entry);
|
|
39
|
+
activeIntersections.delete(entry.target);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const observer = new IntersectionObserver(onIntersectionChange, {
|
|
44
|
+
root,
|
|
45
|
+
rootMargin,
|
|
46
|
+
threshold: typeof amount === "number" ? amount : thresholds[amount],
|
|
47
|
+
});
|
|
48
|
+
elements.forEach((element) => observer.observe(element));
|
|
49
|
+
return () => observer.disconnect();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { inView };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildHTMLStyles } from './utils/build-styles.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { isCSSVariableName } from '../dom/utils/is-css-variable.mjs';
|
|
3
3
|
import { transformProps } from './utils/transform.mjs';
|
|
4
4
|
import { scrapeMotionValuesFromProps } from './utils/scrape-motion-values.mjs';
|
|
5
5
|
import { renderHTML } from './utils/render.mjs';
|
|
@@ -19,7 +19,7 @@ class HTMLVisualElement extends DOMVisualElement {
|
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
21
|
const computedStyle = getComputedStyle(instance);
|
|
22
|
-
const value = (
|
|
22
|
+
const value = (isCSSVariableName(key)
|
|
23
23
|
? computedStyle.getPropertyValue(key)
|
|
24
24
|
: computedStyle[key]) || 0;
|
|
25
25
|
return typeof value === "string" ? value.trim() : value;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildTransform } from './build-transform.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { isCSSVariableName } from '../../dom/utils/is-css-variable.mjs';
|
|
3
3
|
import { transformProps } from './transform.mjs';
|
|
4
4
|
import { getValueAsType } from '../../dom/value-types/get-as-type.mjs';
|
|
5
5
|
import { numberValueTypes } from '../../dom/value-types/number.mjs';
|
|
@@ -22,7 +22,7 @@ function buildHTMLStyles(state, latestValues, options, transformTemplate) {
|
|
|
22
22
|
/**
|
|
23
23
|
* If this is a CSS variable we don't do any further processing.
|
|
24
24
|
*/
|
|
25
|
-
if (
|
|
25
|
+
if (isCSSVariableName(key)) {
|
|
26
26
|
vars[key] = value;
|
|
27
27
|
continue;
|
|
28
28
|
}
|
|
@@ -3,17 +3,16 @@ import { isKeyframesTarget } from '../../animation/utils/is-keyframes-target.mjs
|
|
|
3
3
|
import { shallowCompare } from '../../utils/shallow-compare.mjs';
|
|
4
4
|
import { animateVisualElement } from './animation.mjs';
|
|
5
5
|
import { isVariantLabel } from './is-variant-label.mjs';
|
|
6
|
-
import { AnimationType } from './types.mjs';
|
|
7
6
|
import { resolveVariant } from './resolve-dynamic-variants.mjs';
|
|
8
7
|
|
|
9
8
|
const variantPriorityOrder = [
|
|
10
|
-
AnimationType.Animate
|
|
11
|
-
AnimationType.InView
|
|
12
|
-
AnimationType.Focus
|
|
13
|
-
AnimationType.Hover
|
|
14
|
-
AnimationType.Tap
|
|
15
|
-
AnimationType.Drag
|
|
16
|
-
AnimationType.Exit
|
|
9
|
+
"animate" /* AnimationType.Animate */,
|
|
10
|
+
"whileInView" /* AnimationType.InView */,
|
|
11
|
+
"whileFocus" /* AnimationType.Focus */,
|
|
12
|
+
"whileHover" /* AnimationType.Hover */,
|
|
13
|
+
"whileTap" /* AnimationType.Tap */,
|
|
14
|
+
"whileDrag" /* AnimationType.Drag */,
|
|
15
|
+
"exit" /* AnimationType.Exit */,
|
|
17
16
|
];
|
|
18
17
|
const reversePriorityOrder = [...variantPriorityOrder].reverse();
|
|
19
18
|
const numAnimationTypes = variantPriorityOrder.length;
|
|
@@ -276,16 +275,12 @@ function createAnimationState(visualElement) {
|
|
|
276
275
|
* Change whether a certain animation type is active.
|
|
277
276
|
*/
|
|
278
277
|
function setActive(type, isActive, options) {
|
|
278
|
+
var _a;
|
|
279
279
|
// If the active state hasn't changed, we can safely do nothing here
|
|
280
280
|
if (state[type].isActive === isActive)
|
|
281
281
|
return Promise.resolve();
|
|
282
282
|
// Propagate active change to children
|
|
283
|
-
|
|
284
|
-
visualElement.variantChildren.forEach((child) => {
|
|
285
|
-
child.animationState &&
|
|
286
|
-
child.animationState.setActive(type, isActive);
|
|
287
|
-
});
|
|
288
|
-
}
|
|
283
|
+
(_a = visualElement.variantChildren) === null || _a === void 0 ? void 0 : _a.forEach((child) => { var _a; return (_a = child.animationState) === null || _a === void 0 ? void 0 : _a.setActive(type, isActive); });
|
|
289
284
|
state[type].isActive = isActive;
|
|
290
285
|
const animations = animateChanges(options, type);
|
|
291
286
|
for (const key in state) {
|
|
@@ -319,13 +314,13 @@ function createTypeState(isActive = false) {
|
|
|
319
314
|
}
|
|
320
315
|
function createState() {
|
|
321
316
|
return {
|
|
322
|
-
[AnimationType.Animate]: createTypeState(true),
|
|
323
|
-
[AnimationType.InView]: createTypeState(),
|
|
324
|
-
[AnimationType.Hover]: createTypeState(),
|
|
325
|
-
[AnimationType.Tap]: createTypeState(),
|
|
326
|
-
[AnimationType.Drag]: createTypeState(),
|
|
327
|
-
[AnimationType.Focus]: createTypeState(),
|
|
328
|
-
[AnimationType.Exit]: createTypeState(),
|
|
317
|
+
["animate" /* AnimationType.Animate */]: createTypeState(true),
|
|
318
|
+
["whileInView" /* AnimationType.InView */]: createTypeState(),
|
|
319
|
+
["whileHover" /* AnimationType.Hover */]: createTypeState(),
|
|
320
|
+
["whileTap" /* AnimationType.Tap */]: createTypeState(),
|
|
321
|
+
["whileDrag" /* AnimationType.Drag */]: createTypeState(),
|
|
322
|
+
["whileFocus" /* AnimationType.Focus */]: createTypeState(),
|
|
323
|
+
["exit" /* AnimationType.Exit */]: createTypeState(),
|
|
329
324
|
};
|
|
330
325
|
}
|
|
331
326
|
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { isAnimationControls } from '../../animation/utils/is-animation-controls.mjs';
|
|
2
2
|
import { isVariantLabel } from './is-variant-label.mjs';
|
|
3
|
+
import { variantProps } from './variant-props.mjs';
|
|
3
4
|
|
|
4
|
-
const variantProps = [
|
|
5
|
-
"initial",
|
|
6
|
-
"animate",
|
|
7
|
-
"exit",
|
|
8
|
-
"whileHover",
|
|
9
|
-
"whileDrag",
|
|
10
|
-
"whileTap",
|
|
11
|
-
"whileFocus",
|
|
12
|
-
"whileInView",
|
|
13
|
-
];
|
|
14
5
|
function isControllingVariants(props) {
|
|
15
6
|
return (isAnimationControls(props.animate) ||
|
|
16
7
|
variantProps.some((name) => isVariantLabel(props[name])));
|
|
@@ -22,7 +22,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
22
22
|
* and warn against mismatches.
|
|
23
23
|
*/
|
|
24
24
|
if (process.env.NODE_ENV === "development") {
|
|
25
|
-
warnOnce(nextValue.version === "9.1.
|
|
25
|
+
warnOnce(nextValue.version === "9.1.2", `Attempting to mix Framer Motion versions ${nextValue.version} with 9.1.2 may not work as expected.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
else if (isMotionValue(prevValue)) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const variantPriorityOrder = [
|
|
2
|
+
"animate" /* AnimationType.Animate */,
|
|
3
|
+
"whileInView" /* AnimationType.InView */,
|
|
4
|
+
"whileFocus" /* AnimationType.Focus */,
|
|
5
|
+
"whileHover" /* AnimationType.Hover */,
|
|
6
|
+
"whileTap" /* AnimationType.Tap */,
|
|
7
|
+
"whileDrag" /* AnimationType.Drag */,
|
|
8
|
+
"exit" /* AnimationType.Exit */,
|
|
9
|
+
];
|
|
10
|
+
const variantProps = ["initial", ...variantPriorityOrder];
|
|
11
|
+
|
|
12
|
+
export { variantPriorityOrder, variantProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { noop } from './noop.mjs';
|
|
2
|
+
|
|
3
|
+
let warning = noop;
|
|
4
|
+
let invariant = noop;
|
|
5
|
+
if (process.env.NODE_ENV !== "production") {
|
|
6
|
+
warning = (check, message) => {
|
|
7
|
+
if (!check && typeof console !== "undefined") {
|
|
8
|
+
console.warn(message);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
invariant = (check, message) => {
|
|
12
|
+
if (!check) {
|
|
13
|
+
throw new Error(message);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { invariant, warning };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mix } from './mix.mjs';
|
|
2
|
-
import { invariant } from '
|
|
2
|
+
import { invariant } from './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 { mix } from './mix.mjs';
|
|
2
2
|
import { mixColor } from './mix-color.mjs';
|
|
3
3
|
import { pipe } from './pipe.mjs';
|
|
4
|
-
import { warning } from '
|
|
4
|
+
import { warning } from './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
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mix } from '../mix.mjs';
|
|
2
|
+
import { progress } from '../progress.mjs';
|
|
3
|
+
|
|
4
|
+
function fillOffset(offset, remaining) {
|
|
5
|
+
const min = offset[offset.length - 1];
|
|
6
|
+
for (let i = 1; i <= remaining; i++) {
|
|
7
|
+
const offsetProgress = progress(0, remaining, i);
|
|
8
|
+
offset.push(mix(min, 1, offsetProgress));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { fillOffset };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
-
import { inView } from '
|
|
2
|
+
import { inView } from '../render/dom/viewport/index.mjs';
|
|
3
3
|
|
|
4
4
|
function useInView(ref, { root, margin, amount, once = false } = {}) {
|
|
5
5
|
const [isInView, setInView] = useState(false);
|
package/dist/es/value/index.mjs
CHANGED
|
@@ -25,7 +25,7 @@ class MotionValue {
|
|
|
25
25
|
* This will be replaced by the build step with the latest version number.
|
|
26
26
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
27
27
|
*/
|
|
28
|
-
this.version = "9.1.
|
|
28
|
+
this.version = "9.1.2";
|
|
29
29
|
/**
|
|
30
30
|
* Duration, in milliseconds, since last updating frame.
|
|
31
31
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useTransform } from './use-transform.mjs';
|
|
2
|
-
import { invariant, warning } from '
|
|
2
|
+
import { invariant, warning } from '../utils/errors.mjs';
|
|
3
3
|
import { useMotionValue } from './use-motion-value.mjs';
|
|
4
4
|
import { useVisualElementContext } from '../context/MotionContext/index.mjs';
|
|
5
5
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { scroll } from '@motionone/dom';
|
|
2
1
|
import { motionValue } from './index.mjs';
|
|
3
2
|
import { useConstant } from '../utils/use-constant.mjs';
|
|
4
3
|
import { useEffect } from 'react';
|
|
5
|
-
import { warning } from '
|
|
4
|
+
import { warning } from '../utils/errors.mjs';
|
|
5
|
+
import { scroll } from '../render/dom/scroll/index.mjs';
|
|
6
6
|
import { useIsomorphicLayoutEffect } from '../utils/use-isomorphic-effect.mjs';
|
|
7
7
|
|
|
8
8
|
function refWarning(name, ref) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isCSSVariableName } from '../../render/dom/utils/is-css-variable.mjs';
|
|
2
2
|
import { transformProps } from '../../render/html/utils/transform.mjs';
|
|
3
3
|
import { addUniqueItem, removeItem } from '../../utils/array.mjs';
|
|
4
4
|
import { useConstant } from '../../utils/use-constant.mjs';
|
|
@@ -18,7 +18,7 @@ class WillChangeMotionValue extends MotionValue {
|
|
|
18
18
|
memberName = "transform";
|
|
19
19
|
}
|
|
20
20
|
else if (!name.startsWith("origin") &&
|
|
21
|
-
!
|
|
21
|
+
!isCSSVariableName(name) &&
|
|
22
22
|
name !== "willChange") {
|
|
23
23
|
memberName = camelToDash(name);
|
|
24
24
|
}
|