framer-motion 11.12.0 → 11.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client.js +61 -134
- package/dist/cjs/dom-mini.js +7 -40
- package/dist/cjs/dom.js +40 -67
- package/dist/cjs/index.js +92 -179
- package/dist/cjs/m.js +4 -20
- package/dist/cjs/mini.js +6 -40
- package/dist/client.d.ts +1 -1
- package/dist/dom-mini.d.ts +2 -1
- package/dist/dom-mini.js +1 -1
- package/dist/dom.d.ts +6 -11
- package/dist/dom.js +1 -1
- package/dist/es/animation/animate/resolve-subjects.mjs +1 -1
- package/dist/es/animation/animate/subject.mjs +1 -1
- package/dist/es/animation/animators/AcceleratedAnimation.mjs +1 -1
- package/dist/es/animation/animators/MainThreadAnimation.mjs +1 -1
- package/dist/es/animation/animators/utils/can-animate.mjs +1 -1
- package/dist/es/animation/animators/waapi/NativeAnimation.mjs +1 -2
- package/dist/es/animation/animators/waapi/animate-elements.mjs +2 -2
- package/dist/es/animation/generators/spring/find.mjs +1 -1
- package/dist/es/animation/hooks/animation-controls.mjs +1 -1
- package/dist/es/animation/optimized-appear/start.mjs +1 -1
- package/dist/es/components/AnimatePresence/index.mjs +1 -1
- package/dist/es/components/AnimateSharedLayout.mjs +1 -1
- package/dist/es/components/Reorder/Group.mjs +1 -1
- package/dist/es/components/Reorder/Item.mjs +1 -1
- package/dist/es/dom.mjs +2 -1
- package/dist/es/easing/cubic-bezier.mjs +1 -1
- package/dist/es/easing/utils/map.mjs +1 -2
- package/dist/es/events/event-info.mjs +3 -3
- package/dist/es/frameloop/frame.mjs +1 -1
- package/dist/es/gestures/drag/VisualElementDragControls.mjs +12 -15
- package/dist/es/gestures/drag/index.mjs +1 -1
- package/dist/es/gestures/hover.mjs +18 -22
- package/dist/es/gestures/pan/index.mjs +1 -1
- package/dist/es/gestures/press.mjs +2 -2
- package/dist/es/index.mjs +2 -2
- package/dist/es/motion/index.mjs +1 -1
- package/dist/es/projection/animation/mix-values.mjs +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +1 -1
- package/dist/es/render/dom/resize/handle-element.mjs +1 -1
- package/dist/es/render/dom/scroll/index.mjs +1 -1
- package/dist/es/render/dom/utils/css-variables-conversion.mjs +1 -1
- package/dist/es/render/dom/viewport/index.mjs +1 -1
- package/dist/es/render/utils/motion-values.mjs +1 -1
- package/dist/es/utils/interpolate.mjs +1 -2
- package/dist/es/utils/mix/color.mjs +1 -1
- package/dist/es/utils/mix/complex.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 +1 -1
- package/dist/framer-motion.dev.js +150 -136
- package/dist/framer-motion.js +1 -1
- package/dist/index.d.ts +12 -19
- package/dist/m.d.ts +1 -1
- package/dist/mini.d.ts +264 -15
- package/dist/mini.js +1 -1
- package/dist/three.d.ts +1 -3
- package/package.json +8 -6
- package/dist/es/gestures/drag/utils/lock.mjs +0 -53
- package/dist/es/render/dom/utils/resolve-element.mjs +0 -28
- package/dist/es/utils/errors.mjs +0 -18
- package/dist/es/utils/noop.mjs +0 -3
package/dist/cjs/client.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var motionUtils = require('motion-utils');
|
|
6
|
+
var motionDom = require('motion-dom');
|
|
5
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
8
|
var react = require('react');
|
|
7
9
|
|
|
@@ -183,8 +185,6 @@ function getFinalKeyframe(keyframes, { repeat, repeatType = "loop" }, finalKeyfr
|
|
|
183
185
|
: finalKeyframe;
|
|
184
186
|
}
|
|
185
187
|
|
|
186
|
-
const noop = (any) => any;
|
|
187
|
-
|
|
188
188
|
function createRenderStep(runNextFrame) {
|
|
189
189
|
/**
|
|
190
190
|
* We create and reuse two queues, one to queue jobs for the current frame
|
|
@@ -332,7 +332,7 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
|
|
|
332
332
|
return { schedule, cancel, state, steps };
|
|
333
333
|
}
|
|
334
334
|
|
|
335
|
-
const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps, } = createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : noop, true);
|
|
335
|
+
const { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps, } = createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : motionUtils.noop, true);
|
|
336
336
|
|
|
337
337
|
/*
|
|
338
338
|
Bezier function generator
|
|
@@ -376,7 +376,7 @@ function binarySubdivide(x, lowerBound, upperBound, mX1, mX2) {
|
|
|
376
376
|
function cubicBezier(mX1, mY1, mX2, mY2) {
|
|
377
377
|
// If this is a linear gradient, return linear easing
|
|
378
378
|
if (mX1 === mY1 && mX2 === mY2)
|
|
379
|
-
return noop;
|
|
379
|
+
return motionUtils.noop;
|
|
380
380
|
const getTForX = (aX) => binarySubdivide(aX, 0, 1, mX1, mX2);
|
|
381
381
|
// If animation is at start/end, return t without easing
|
|
382
382
|
return (t) => t === 0 || t === 1 ? t : calcBezier(getTForX(t), mY1, mY2);
|
|
@@ -417,21 +417,6 @@ function isNone(value) {
|
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
-
let warning = noop;
|
|
421
|
-
let invariant = noop;
|
|
422
|
-
if (process.env.NODE_ENV !== "production") {
|
|
423
|
-
warning = (check, message) => {
|
|
424
|
-
if (!check && typeof console !== "undefined") {
|
|
425
|
-
console.warn(message);
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
invariant = (check, message) => {
|
|
429
|
-
if (!check) {
|
|
430
|
-
throw new Error(message);
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
|
|
435
420
|
/**
|
|
436
421
|
* Check if value is a numerical string, ie a string that is purely a number eg "100" or "-100.1"
|
|
437
422
|
*/
|
|
@@ -472,7 +457,7 @@ function parseCSSVariable(current) {
|
|
|
472
457
|
}
|
|
473
458
|
const maxDepth = 4;
|
|
474
459
|
function getVariableValue(current, element, depth = 1) {
|
|
475
|
-
invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`);
|
|
460
|
+
motionUtils.invariant(depth <= maxDepth, `Max CSS variable fallback depth detected in property "${current}". This may indicate a circular fallback dependency.`);
|
|
476
461
|
const [token, fallback] = parseCSSVariable(current);
|
|
477
462
|
// No CSS variable detected
|
|
478
463
|
if (!token)
|
|
@@ -1360,7 +1345,7 @@ function canAnimate(keyframes, name, type, velocity) {
|
|
|
1360
1345
|
const targetKeyframe = keyframes[keyframes.length - 1];
|
|
1361
1346
|
const isOriginAnimatable = isAnimatable(originKeyframe, name);
|
|
1362
1347
|
const isTargetAnimatable = isAnimatable(targetKeyframe, name);
|
|
1363
|
-
warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${name} from "${originKeyframe}" to "${targetKeyframe}". ${originKeyframe} is not an animatable value - to enable this animation set ${originKeyframe} to a value animatable to ${targetKeyframe} via the \`style\` property.`);
|
|
1348
|
+
motionUtils.warning(isOriginAnimatable === isTargetAnimatable, `You are trying to animate ${name} from "${originKeyframe}" to "${targetKeyframe}". ${originKeyframe} is not an animatable value - to enable this animation set ${originKeyframe} to a value animatable to ${targetKeyframe} via the \`style\` property.`);
|
|
1364
1349
|
// Always skip if any of these are true
|
|
1365
1350
|
if (!isOriginAnimatable || !isTargetAnimatable) {
|
|
1366
1351
|
return false;
|
|
@@ -1553,7 +1538,7 @@ const safeMin = 0.001;
|
|
|
1553
1538
|
function findSpring({ duration = springDefaults.duration, bounce = springDefaults.bounce, velocity = springDefaults.velocity, mass = springDefaults.mass, }) {
|
|
1554
1539
|
let envelope;
|
|
1555
1540
|
let derivative;
|
|
1556
|
-
warning(duration <= secondsToMilliseconds(springDefaults.maxDuration), "Spring duration must be 10 seconds or less");
|
|
1541
|
+
motionUtils.warning(duration <= secondsToMilliseconds(springDefaults.maxDuration), "Spring duration must be 10 seconds or less");
|
|
1557
1542
|
let dampingRatio = 1 - bounce;
|
|
1558
1543
|
/**
|
|
1559
1544
|
* Restrict dampingRatio and duration to within acceptable ranges.
|
|
@@ -1895,7 +1880,7 @@ const isEasingArray = (ease) => {
|
|
|
1895
1880
|
const isBezierDefinition = (easing) => Array.isArray(easing) && typeof easing[0] === "number";
|
|
1896
1881
|
|
|
1897
1882
|
const easingLookup = {
|
|
1898
|
-
linear: noop,
|
|
1883
|
+
linear: motionUtils.noop,
|
|
1899
1884
|
easeIn,
|
|
1900
1885
|
easeInOut,
|
|
1901
1886
|
easeOut,
|
|
@@ -1910,13 +1895,13 @@ const easingLookup = {
|
|
|
1910
1895
|
const easingDefinitionToFunction = (definition) => {
|
|
1911
1896
|
if (isBezierDefinition(definition)) {
|
|
1912
1897
|
// If cubic bezier definition, create bezier curve
|
|
1913
|
-
invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`);
|
|
1898
|
+
motionUtils.invariant(definition.length === 4, `Cubic bezier arrays must contain four numerical values.`);
|
|
1914
1899
|
const [x1, y1, x2, y2] = definition;
|
|
1915
1900
|
return cubicBezier(x1, y1, x2, y2);
|
|
1916
1901
|
}
|
|
1917
1902
|
else if (typeof definition === "string") {
|
|
1918
1903
|
// Else lookup from table
|
|
1919
|
-
invariant(easingLookup[definition] !== undefined, `Invalid easing type '${definition}'`);
|
|
1904
|
+
motionUtils.invariant(easingLookup[definition] !== undefined, `Invalid easing type '${definition}'`);
|
|
1920
1905
|
return easingLookup[definition];
|
|
1921
1906
|
}
|
|
1922
1907
|
return definition;
|
|
@@ -2014,7 +1999,7 @@ const colorTypes = [hex, rgba, hsla];
|
|
|
2014
1999
|
const getColorType = (v) => colorTypes.find((type) => type.test(v));
|
|
2015
2000
|
function asRGBA(color) {
|
|
2016
2001
|
const type = getColorType(color);
|
|
2017
|
-
warning(Boolean(type), `'${color}' is not an animatable color. Use the equivalent color code instead.`);
|
|
2002
|
+
motionUtils.warning(Boolean(type), `'${color}' is not an animatable color. Use the equivalent color code instead.`);
|
|
2018
2003
|
if (!Boolean(type))
|
|
2019
2004
|
return false;
|
|
2020
2005
|
let model = type.parse(color);
|
|
@@ -2133,7 +2118,7 @@ const mixComplex = (origin, target) => {
|
|
|
2133
2118
|
return pipe(mixArray(matchOrder(originStats, targetStats), targetStats.values), template);
|
|
2134
2119
|
}
|
|
2135
2120
|
else {
|
|
2136
|
-
warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
|
|
2121
|
+
motionUtils.warning(true, `Complex values '${origin}' and '${target}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`);
|
|
2137
2122
|
return mixImmediate(origin, target);
|
|
2138
2123
|
}
|
|
2139
2124
|
};
|
|
@@ -2155,7 +2140,7 @@ function createMixers(output, ease, customMixer) {
|
|
|
2155
2140
|
for (let i = 0; i < numMixers; i++) {
|
|
2156
2141
|
let mixer = mixerFactory(output[i], output[i + 1]);
|
|
2157
2142
|
if (ease) {
|
|
2158
|
-
const easingFunction = Array.isArray(ease) ? ease[i] || noop : ease;
|
|
2143
|
+
const easingFunction = Array.isArray(ease) ? ease[i] || motionUtils.noop : ease;
|
|
2159
2144
|
mixer = pipe(easingFunction, mixer);
|
|
2160
2145
|
}
|
|
2161
2146
|
mixers.push(mixer);
|
|
@@ -2183,7 +2168,7 @@ function createMixers(output, ease, customMixer) {
|
|
|
2183
2168
|
*/
|
|
2184
2169
|
function interpolate(input, output, { clamp: isClamp = true, ease, mixer } = {}) {
|
|
2185
2170
|
const inputLength = input.length;
|
|
2186
|
-
invariant(inputLength === output.length, "Both input and output ranges must be the same length");
|
|
2171
|
+
motionUtils.invariant(inputLength === output.length, "Both input and output ranges must be the same length");
|
|
2187
2172
|
/**
|
|
2188
2173
|
* If we're only provided a single input, we can just make a function
|
|
2189
2174
|
* that returns the output.
|
|
@@ -2374,7 +2359,7 @@ class MainThreadAnimation extends BaseAnimation {
|
|
|
2374
2359
|
if (generatorFactory !== keyframes &&
|
|
2375
2360
|
typeof keyframes$1[0] !== "number") {
|
|
2376
2361
|
if (process.env.NODE_ENV !== "production") {
|
|
2377
|
-
invariant(keyframes$1.length === 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${keyframes$1}`);
|
|
2362
|
+
motionUtils.invariant(keyframes$1.length === 2, `Only two keyframes currently supported with spring and inertia animations. Trying to animate ${keyframes$1}`);
|
|
2378
2363
|
}
|
|
2379
2364
|
mapPercentToKeyframes = pipe(percentToProgress, mix(keyframes$1[0], keyframes$1[1]));
|
|
2380
2365
|
keyframes$1 = [0, 100];
|
|
@@ -2975,11 +2960,11 @@ class AcceleratedAnimation extends BaseAnimation {
|
|
|
2975
2960
|
else {
|
|
2976
2961
|
const { resolved } = this;
|
|
2977
2962
|
if (!resolved)
|
|
2978
|
-
return noop;
|
|
2963
|
+
return motionUtils.noop;
|
|
2979
2964
|
const { animation } = resolved;
|
|
2980
2965
|
attachTimeline(animation, timeline);
|
|
2981
2966
|
}
|
|
2982
|
-
return noop;
|
|
2967
|
+
return motionUtils.noop;
|
|
2983
2968
|
}
|
|
2984
2969
|
play() {
|
|
2985
2970
|
if (this.isStopped)
|
|
@@ -3348,7 +3333,7 @@ class MotionValue {
|
|
|
3348
3333
|
* This will be replaced by the build step with the latest version number.
|
|
3349
3334
|
* When MotionValues are provided to motion components, warn if versions are mixed.
|
|
3350
3335
|
*/
|
|
3351
|
-
this.version = "11.
|
|
3336
|
+
this.version = "11.13.0";
|
|
3352
3337
|
/**
|
|
3353
3338
|
* Tracks whether this value can output a velocity. Currently this is only true
|
|
3354
3339
|
* if the value is numerical, but we might be able to widen the scope here and support
|
|
@@ -4271,11 +4256,11 @@ const isPrimaryPointer = (event) => {
|
|
|
4271
4256
|
}
|
|
4272
4257
|
};
|
|
4273
4258
|
|
|
4274
|
-
function extractEventInfo(event
|
|
4259
|
+
function extractEventInfo(event) {
|
|
4275
4260
|
return {
|
|
4276
4261
|
point: {
|
|
4277
|
-
x: event
|
|
4278
|
-
y: event
|
|
4262
|
+
x: event.pageX,
|
|
4263
|
+
y: event.pageY,
|
|
4279
4264
|
},
|
|
4280
4265
|
};
|
|
4281
4266
|
}
|
|
@@ -4447,58 +4432,6 @@ function getVelocity(history, timeDelta) {
|
|
|
4447
4432
|
return currentVelocity;
|
|
4448
4433
|
}
|
|
4449
4434
|
|
|
4450
|
-
function createLock(name) {
|
|
4451
|
-
let lock = null;
|
|
4452
|
-
return () => {
|
|
4453
|
-
const openLock = () => {
|
|
4454
|
-
lock = null;
|
|
4455
|
-
};
|
|
4456
|
-
if (lock === null) {
|
|
4457
|
-
lock = name;
|
|
4458
|
-
return openLock;
|
|
4459
|
-
}
|
|
4460
|
-
return false;
|
|
4461
|
-
};
|
|
4462
|
-
}
|
|
4463
|
-
const globalHorizontalLock = createLock("dragHorizontal");
|
|
4464
|
-
const globalVerticalLock = createLock("dragVertical");
|
|
4465
|
-
function getGlobalLock(drag) {
|
|
4466
|
-
let lock = false;
|
|
4467
|
-
if (drag === "y") {
|
|
4468
|
-
lock = globalVerticalLock();
|
|
4469
|
-
}
|
|
4470
|
-
else if (drag === "x") {
|
|
4471
|
-
lock = globalHorizontalLock();
|
|
4472
|
-
}
|
|
4473
|
-
else {
|
|
4474
|
-
const openHorizontal = globalHorizontalLock();
|
|
4475
|
-
const openVertical = globalVerticalLock();
|
|
4476
|
-
if (openHorizontal && openVertical) {
|
|
4477
|
-
lock = () => {
|
|
4478
|
-
openHorizontal();
|
|
4479
|
-
openVertical();
|
|
4480
|
-
};
|
|
4481
|
-
}
|
|
4482
|
-
else {
|
|
4483
|
-
// Release the locks because we don't use them
|
|
4484
|
-
if (openHorizontal)
|
|
4485
|
-
openHorizontal();
|
|
4486
|
-
if (openVertical)
|
|
4487
|
-
openVertical();
|
|
4488
|
-
}
|
|
4489
|
-
}
|
|
4490
|
-
return lock;
|
|
4491
|
-
}
|
|
4492
|
-
function isDragActive() {
|
|
4493
|
-
// Check the gesture lock - if we get it, it means no drag gesture is active
|
|
4494
|
-
// and we can safely fire the tap gesture.
|
|
4495
|
-
const openGestureLock = getGlobalLock(true);
|
|
4496
|
-
if (!openGestureLock)
|
|
4497
|
-
return true;
|
|
4498
|
-
openGestureLock();
|
|
4499
|
-
return false;
|
|
4500
|
-
}
|
|
4501
|
-
|
|
4502
4435
|
function isRefObject(ref) {
|
|
4503
4436
|
return (ref &&
|
|
4504
4437
|
typeof ref === "object" &&
|
|
@@ -4894,10 +4827,7 @@ const elementDragControls = new WeakMap();
|
|
|
4894
4827
|
// let latestPointerEvent: PointerEvent
|
|
4895
4828
|
class VisualElementDragControls {
|
|
4896
4829
|
constructor(visualElement) {
|
|
4897
|
-
|
|
4898
|
-
// can "capture" the drag of one or both axes.
|
|
4899
|
-
// TODO: Look into moving this into pansession?
|
|
4900
|
-
this.openGlobalLock = null;
|
|
4830
|
+
this.openDragLock = null;
|
|
4901
4831
|
this.isDragging = false;
|
|
4902
4832
|
this.currentDirection = null;
|
|
4903
4833
|
this.originPoint = { x: 0, y: 0 };
|
|
@@ -4925,18 +4855,18 @@ class VisualElementDragControls {
|
|
|
4925
4855
|
// the component.
|
|
4926
4856
|
dragSnapToOrigin ? this.pauseAnimation() : this.stopAnimation();
|
|
4927
4857
|
if (snapToCursor) {
|
|
4928
|
-
this.snapToCursor(extractEventInfo(event
|
|
4858
|
+
this.snapToCursor(extractEventInfo(event).point);
|
|
4929
4859
|
}
|
|
4930
4860
|
};
|
|
4931
4861
|
const onStart = (event, info) => {
|
|
4932
4862
|
// Attempt to grab the global drag gesture lock - maybe make this part of PanSession
|
|
4933
4863
|
const { drag, dragPropagation, onDragStart } = this.getProps();
|
|
4934
4864
|
if (drag && !dragPropagation) {
|
|
4935
|
-
if (this.
|
|
4936
|
-
this.
|
|
4937
|
-
this.
|
|
4865
|
+
if (this.openDragLock)
|
|
4866
|
+
this.openDragLock();
|
|
4867
|
+
this.openDragLock = motionDom.setDragLock(drag);
|
|
4938
4868
|
// If we don 't have the lock, don't start dragging
|
|
4939
|
-
if (!this.
|
|
4869
|
+
if (!this.openDragLock)
|
|
4940
4870
|
return;
|
|
4941
4871
|
}
|
|
4942
4872
|
this.isDragging = true;
|
|
@@ -4978,7 +4908,7 @@ class VisualElementDragControls {
|
|
|
4978
4908
|
// latestPointerEvent = event
|
|
4979
4909
|
const { dragPropagation, dragDirectionLock, onDirectionLock, onDrag, } = this.getProps();
|
|
4980
4910
|
// If we didn't successfully receive the gesture lock, early return.
|
|
4981
|
-
if (!dragPropagation && !this.
|
|
4911
|
+
if (!dragPropagation && !this.openDragLock)
|
|
4982
4912
|
return;
|
|
4983
4913
|
const { offset } = info;
|
|
4984
4914
|
// Attempt to detect drag direction if directionLock is true
|
|
@@ -5046,9 +4976,9 @@ class VisualElementDragControls {
|
|
|
5046
4976
|
this.panSession && this.panSession.end();
|
|
5047
4977
|
this.panSession = undefined;
|
|
5048
4978
|
const { dragPropagation } = this.getProps();
|
|
5049
|
-
if (!dragPropagation && this.
|
|
5050
|
-
this.
|
|
5051
|
-
this.
|
|
4979
|
+
if (!dragPropagation && this.openDragLock) {
|
|
4980
|
+
this.openDragLock();
|
|
4981
|
+
this.openDragLock = null;
|
|
5052
4982
|
}
|
|
5053
4983
|
animationState && animationState.setActive("whileDrag", false);
|
|
5054
4984
|
}
|
|
@@ -5108,7 +5038,7 @@ class VisualElementDragControls {
|
|
|
5108
5038
|
if (!constraints || !isRefObject(constraints))
|
|
5109
5039
|
return false;
|
|
5110
5040
|
const constraintsElement = constraints.current;
|
|
5111
|
-
invariant(constraintsElement !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");
|
|
5041
|
+
motionUtils.invariant(constraintsElement !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");
|
|
5112
5042
|
const { projection } = this.visualElement;
|
|
5113
5043
|
// TODO
|
|
5114
5044
|
if (!projection || !projection.layout)
|
|
@@ -5356,8 +5286,8 @@ function getCurrentDirection(offset, lockThreshold = 10) {
|
|
|
5356
5286
|
class DragGesture extends Feature {
|
|
5357
5287
|
constructor(node) {
|
|
5358
5288
|
super(node);
|
|
5359
|
-
this.removeGroupControls = noop;
|
|
5360
|
-
this.removeListeners = noop;
|
|
5289
|
+
this.removeGroupControls = motionUtils.noop;
|
|
5290
|
+
this.removeListeners = motionUtils.noop;
|
|
5361
5291
|
this.controls = new VisualElementDragControls(node);
|
|
5362
5292
|
}
|
|
5363
5293
|
mount() {
|
|
@@ -5367,7 +5297,7 @@ class DragGesture extends Feature {
|
|
|
5367
5297
|
if (dragControls) {
|
|
5368
5298
|
this.removeGroupControls = dragControls.subscribe(this.controls);
|
|
5369
5299
|
}
|
|
5370
|
-
this.removeListeners = this.controls.addListeners() || noop;
|
|
5300
|
+
this.removeListeners = this.controls.addListeners() || motionUtils.noop;
|
|
5371
5301
|
}
|
|
5372
5302
|
unmount() {
|
|
5373
5303
|
this.removeGroupControls();
|
|
@@ -5383,7 +5313,7 @@ const asyncHandler = (handler) => (event, info) => {
|
|
|
5383
5313
|
class PanGesture extends Feature {
|
|
5384
5314
|
constructor() {
|
|
5385
5315
|
super(...arguments);
|
|
5386
|
-
this.removePointerDownListener = noop;
|
|
5316
|
+
this.removePointerDownListener = motionUtils.noop;
|
|
5387
5317
|
}
|
|
5388
5318
|
onPointerDown(pointerDownEvent) {
|
|
5389
5319
|
this.session = new PanSession(pointerDownEvent, this.createPanHandlers(), {
|
|
@@ -5491,7 +5421,7 @@ function getRadius(values, radiusName) {
|
|
|
5491
5421
|
// )(p)
|
|
5492
5422
|
// }
|
|
5493
5423
|
const easeCrossfadeIn = /*@__PURE__*/ compress(0, 0.5, circOut);
|
|
5494
|
-
const easeCrossfadeOut = /*@__PURE__*/ compress(0.5, 0.95, noop);
|
|
5424
|
+
const easeCrossfadeOut = /*@__PURE__*/ compress(0.5, 0.95, motionUtils.noop);
|
|
5495
5425
|
function compress(min, max, easing) {
|
|
5496
5426
|
return (p) => {
|
|
5497
5427
|
// Could replace ifs with clamp
|
|
@@ -5927,7 +5857,7 @@ function updateMotionValuesFromProps(element, next, prev) {
|
|
|
5927
5857
|
* and warn against mismatches.
|
|
5928
5858
|
*/
|
|
5929
5859
|
if (process.env.NODE_ENV === "development") {
|
|
5930
|
-
warnOnce(nextValue.version === "11.
|
|
5860
|
+
warnOnce(nextValue.version === "11.13.0", `Attempting to mix Motion versions ${nextValue.version} with 11.13.0 may not work as expected.`);
|
|
5931
5861
|
}
|
|
5932
5862
|
}
|
|
5933
5863
|
else if (isMotionValue(prevValue)) {
|
|
@@ -8362,7 +8292,7 @@ const userAgentContains = (string) => typeof navigator !== "undefined" &&
|
|
|
8362
8292
|
*/
|
|
8363
8293
|
const roundPoint = userAgentContains("applewebkit/") && !userAgentContains("chrome/")
|
|
8364
8294
|
? Math.round
|
|
8365
|
-
: noop;
|
|
8295
|
+
: motionUtils.noop;
|
|
8366
8296
|
function roundAxis(axis) {
|
|
8367
8297
|
// Round to the nearest .5 pixels to support subpixel layouts
|
|
8368
8298
|
axis.min = roundPoint(axis.min);
|
|
@@ -8662,28 +8592,25 @@ const drag = {
|
|
|
8662
8592
|
},
|
|
8663
8593
|
};
|
|
8664
8594
|
|
|
8665
|
-
function
|
|
8666
|
-
const
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
}
|
|
8675
|
-
const callback = props[callbackName];
|
|
8676
|
-
if (callback) {
|
|
8677
|
-
frame.postRender(() => callback(event, info));
|
|
8678
|
-
}
|
|
8679
|
-
};
|
|
8680
|
-
return addPointerEvent(node.current, eventName, handleEvent, {
|
|
8681
|
-
passive: !node.getProps()[callbackName],
|
|
8682
|
-
});
|
|
8595
|
+
function handleHoverEvent(node, event, isActive) {
|
|
8596
|
+
const { props } = node;
|
|
8597
|
+
if (node.animationState && props.whileHover) {
|
|
8598
|
+
node.animationState.setActive("whileHover", isActive);
|
|
8599
|
+
}
|
|
8600
|
+
const callback = props[isActive ? "onHoverStart" : "onHoverEnd"];
|
|
8601
|
+
if (callback) {
|
|
8602
|
+
frame.postRender(() => callback(event, extractEventInfo(event)));
|
|
8603
|
+
}
|
|
8683
8604
|
}
|
|
8684
8605
|
class HoverGesture extends Feature {
|
|
8685
8606
|
mount() {
|
|
8686
|
-
|
|
8607
|
+
const { current, props } = this.node;
|
|
8608
|
+
if (!current)
|
|
8609
|
+
return;
|
|
8610
|
+
this.unmount = motionDom.hover(current, (startEvent) => {
|
|
8611
|
+
handleHoverEvent(this.node, startEvent, true);
|
|
8612
|
+
return (endEvent) => handleHoverEvent(this.node, endEvent, false);
|
|
8613
|
+
}, { passive: !props.onHoverStart && !props.onHoverEnd });
|
|
8687
8614
|
}
|
|
8688
8615
|
unmount() { }
|
|
8689
8616
|
}
|
|
@@ -8752,9 +8679,9 @@ function fireSyntheticPointerEvent(name, handler) {
|
|
|
8752
8679
|
class PressGesture extends Feature {
|
|
8753
8680
|
constructor() {
|
|
8754
8681
|
super(...arguments);
|
|
8755
|
-
this.removeStartListeners = noop;
|
|
8756
|
-
this.removeEndListeners = noop;
|
|
8757
|
-
this.removeAccessibleListeners = noop;
|
|
8682
|
+
this.removeStartListeners = motionUtils.noop;
|
|
8683
|
+
this.removeEndListeners = motionUtils.noop;
|
|
8684
|
+
this.removeAccessibleListeners = motionUtils.noop;
|
|
8758
8685
|
this.startPointerPress = (startEvent, startInfo) => {
|
|
8759
8686
|
if (this.isPressing)
|
|
8760
8687
|
return;
|
|
@@ -8836,7 +8763,7 @@ class PressGesture extends Feature {
|
|
|
8836
8763
|
if (props.whileTap && this.node.animationState) {
|
|
8837
8764
|
this.node.animationState.setActive("whileTap", false);
|
|
8838
8765
|
}
|
|
8839
|
-
return !isDragActive();
|
|
8766
|
+
return !motionDom.isDragActive();
|
|
8840
8767
|
}
|
|
8841
8768
|
cancelPress(event, info) {
|
|
8842
8769
|
if (!this.checkPressEnd())
|
|
@@ -9265,8 +9192,8 @@ function useStrictMode(configAndProps, preloadedFeatures) {
|
|
|
9265
9192
|
isStrict) {
|
|
9266
9193
|
const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
|
|
9267
9194
|
configAndProps.ignoreStrict
|
|
9268
|
-
? warning(false, strictMessage)
|
|
9269
|
-
: invariant(false, strictMessage);
|
|
9195
|
+
? motionUtils.warning(false, strictMessage)
|
|
9196
|
+
: motionUtils.invariant(false, strictMessage);
|
|
9270
9197
|
}
|
|
9271
9198
|
}
|
|
9272
9199
|
function getProjectionFunctionality(props) {
|
package/dist/cjs/dom-mini.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var motionDom = require('motion-dom');
|
|
6
|
+
var motionUtils = require('motion-utils');
|
|
7
|
+
|
|
5
8
|
function memo(callback) {
|
|
6
9
|
let result;
|
|
7
10
|
return () => {
|
|
@@ -91,42 +94,6 @@ class GroupPlaybackControls {
|
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
const noop = (any) => any;
|
|
95
|
-
|
|
96
|
-
let invariant = noop;
|
|
97
|
-
if (process.env.NODE_ENV !== "production") {
|
|
98
|
-
invariant = (check, message) => {
|
|
99
|
-
if (!check) {
|
|
100
|
-
throw new Error(message);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function resolveElements(elements, scope, selectorCache) {
|
|
106
|
-
var _a;
|
|
107
|
-
if (typeof elements === "string") {
|
|
108
|
-
let root = document;
|
|
109
|
-
if (scope) {
|
|
110
|
-
invariant(Boolean(scope.current), "Scope provided, but no element detected.");
|
|
111
|
-
root = scope.current;
|
|
112
|
-
}
|
|
113
|
-
if (selectorCache) {
|
|
114
|
-
(_a = selectorCache[elements]) !== null && _a !== void 0 ? _a : (selectorCache[elements] = root.querySelectorAll(elements));
|
|
115
|
-
elements = selectorCache[elements];
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
elements = root.querySelectorAll(elements);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else if (elements instanceof Element) {
|
|
122
|
-
elements = [elements];
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Return an empty array
|
|
126
|
-
*/
|
|
127
|
-
return Array.from(elements || []);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
97
|
/**
|
|
131
98
|
* Converts seconds to milliseconds
|
|
132
99
|
*
|
|
@@ -390,7 +357,7 @@ class NativeAnimation {
|
|
|
390
357
|
this.setValue = isCSSVar ? setCSSVar : setStyle;
|
|
391
358
|
this.options = options;
|
|
392
359
|
this.updateFinishedPromise();
|
|
393
|
-
invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "framer-motion"?`);
|
|
360
|
+
motionUtils.invariant(typeof options.type !== "string", `animateMini doesn't support "type" as a string. Did you mean to import { spring } from "framer-motion"?`);
|
|
394
361
|
const existingAnimation = getElementAnimationState(element).get(valueName);
|
|
395
362
|
existingAnimation && existingAnimation.stop();
|
|
396
363
|
const readInitialKeyframe = () => {
|
|
@@ -520,14 +487,14 @@ class NativeAnimation {
|
|
|
520
487
|
else {
|
|
521
488
|
attachTimeline(this.animation, timeline);
|
|
522
489
|
}
|
|
523
|
-
return noop;
|
|
490
|
+
return motionUtils.noop;
|
|
524
491
|
}
|
|
525
492
|
}
|
|
526
493
|
|
|
527
494
|
function animateElements(elementOrSelector, keyframes, options, scope) {
|
|
528
|
-
const elements = resolveElements(elementOrSelector, scope);
|
|
495
|
+
const elements = motionDom.resolveElements(elementOrSelector, scope);
|
|
529
496
|
const numElements = elements.length;
|
|
530
|
-
invariant(Boolean(numElements), "No valid element provided.");
|
|
497
|
+
motionUtils.invariant(Boolean(numElements), "No valid element provided.");
|
|
531
498
|
const animations = [];
|
|
532
499
|
for (let i = 0; i < numElements; i++) {
|
|
533
500
|
const element = elements[i];
|