motion 10.3.2 → 10.5.0-alpha.3
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 +0 -19
- package/dist/main.cjs.js +11 -13
- package/dist/main.es.js +7 -6
- package/dist/motion.min.js +1 -1
- package/dist/motion.umd.js +412 -16
- package/dist/react.cjs.js +7 -2
- package/dist/react.es.js +1 -1
- package/dist/size-index.js +1 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/lib/react.js +2 -0
- package/lib/react.js.map +1 -0
- package/lib/vue.js +2 -0
- package/lib/vue.js.map +1 -0
- package/package.json +16 -134
- package/react/package.json +1 -1
- package/types/index.d.ts +3 -7
- package/types/index.d.ts.map +1 -0
- package/types/react.d.ts +2 -0
- package/types/react.d.ts.map +1 -0
- package/types/vue.d.ts +2 -0
- package/types/vue.d.ts.map +1 -0
- package/CHANGELOG.md +0 -97
- package/dist/size-animate-dom.js +0 -1
- package/dist/size-animate-style.js +0 -1
- package/dist/size-react.js +0 -1
- package/dist/size-spring.js +0 -1
- package/dist/size-timeline-dom.js +0 -1
- package/dist/size-webpack-animate.js +0 -1
- package/dist/targets/dom/animate-style.cjs.js +0 -182
- package/dist/targets/dom/animate-style.es.js +0 -178
- package/dist/targets/dom/animate.cjs.js +0 -42
- package/dist/targets/dom/animate.es.js +0 -38
- package/dist/targets/dom/data.cjs.js +0 -18
- package/dist/targets/dom/data.es.js +0 -14
- package/dist/targets/dom/style.cjs.js +0 -22
- package/dist/targets/dom/style.es.js +0 -18
- package/dist/targets/dom/timeline/index.cjs.js +0 -174
- package/dist/targets/dom/timeline/index.es.js +0 -169
- package/dist/targets/dom/timeline/utils/calc-time.cjs.js +0 -23
- package/dist/targets/dom/timeline/utils/calc-time.es.js +0 -19
- package/dist/targets/dom/timeline/utils/edit.cjs.js +0 -36
- package/dist/targets/dom/timeline/utils/edit.es.js +0 -31
- package/dist/targets/dom/timeline/utils/sort.cjs.js +0 -14
- package/dist/targets/dom/timeline/utils/sort.es.js +0 -10
- package/dist/targets/dom/utils/apply.cjs.js +0 -9
- package/dist/targets/dom/utils/apply.es.js +0 -4
- package/dist/targets/dom/utils/controls.cjs.js +0 -59
- package/dist/targets/dom/utils/controls.es.js +0 -54
- package/dist/targets/dom/utils/css-var.cjs.js +0 -29
- package/dist/targets/dom/utils/css-var.es.js +0 -23
- package/dist/targets/dom/utils/defaults.cjs.js +0 -13
- package/dist/targets/dom/utils/defaults.es.js +0 -9
- package/dist/targets/dom/utils/easing.cjs.js +0 -18
- package/dist/targets/dom/utils/easing.es.js +0 -10
- package/dist/targets/dom/utils/feature-detection.cjs.js +0 -31
- package/dist/targets/dom/utils/feature-detection.es.js +0 -27
- package/dist/targets/dom/utils/get-style-name.cjs.js +0 -13
- package/dist/targets/dom/utils/get-style-name.es.js +0 -9
- package/dist/targets/dom/utils/keyframes.cjs.js +0 -16
- package/dist/targets/dom/utils/keyframes.es.js +0 -11
- package/dist/targets/dom/utils/options.cjs.js +0 -13
- package/dist/targets/dom/utils/options.es.js +0 -9
- package/dist/targets/dom/utils/resolve-elements.cjs.js +0 -22
- package/dist/targets/dom/utils/resolve-elements.es.js +0 -18
- package/dist/targets/dom/utils/stop-animation.cjs.js +0 -19
- package/dist/targets/dom/utils/stop-animation.es.js +0 -15
- package/dist/targets/dom/utils/time.cjs.js +0 -7
- package/dist/targets/dom/utils/time.es.js +0 -3
- package/dist/targets/dom/utils/transforms.cjs.js +0 -85
- package/dist/targets/dom/utils/transforms.es.js +0 -74
- package/dist/targets/js/NumberAnimation.cjs.js +0 -144
- package/dist/targets/js/NumberAnimation.es.js +0 -140
- package/dist/targets/js/easing/cubic-bezier.cjs.js +0 -57
- package/dist/targets/js/easing/cubic-bezier.es.js +0 -53
- package/dist/targets/js/easing/glide/generator.cjs.js +0 -99
- package/dist/targets/js/easing/glide/generator.es.js +0 -95
- package/dist/targets/js/easing/glide/index.cjs.js +0 -10
- package/dist/targets/js/easing/glide/index.es.js +0 -6
- package/dist/targets/js/easing/spring/generator.cjs.js +0 -64
- package/dist/targets/js/easing/spring/generator.es.js +0 -57
- package/dist/targets/js/easing/spring/index.cjs.js +0 -10
- package/dist/targets/js/easing/spring/index.es.js +0 -6
- package/dist/targets/js/easing/steps.cjs.js +0 -15
- package/dist/targets/js/easing/steps.es.js +0 -11
- package/dist/targets/js/easing/utils/create-generator-easing.cjs.js +0 -71
- package/dist/targets/js/easing/utils/create-generator-easing.es.js +0 -67
- package/dist/targets/js/easing/utils/get-function.cjs.js +0 -37
- package/dist/targets/js/easing/utils/get-function.es.js +0 -33
- package/dist/targets/js/easing/utils/has-reached-target.cjs.js +0 -10
- package/dist/targets/js/easing/utils/has-reached-target.es.js +0 -6
- package/dist/targets/js/easing/utils/pregenerate-keyframes.cjs.js +0 -34
- package/dist/targets/js/easing/utils/pregenerate-keyframes.es.js +0 -30
- package/dist/targets/js/utils/get-easing.cjs.js +0 -14
- package/dist/targets/js/utils/get-easing.es.js +0 -10
- package/dist/targets/js/utils/interpolate.cjs.js +0 -35
- package/dist/targets/js/utils/interpolate.es.js +0 -31
- package/dist/targets/js/utils/offset.cjs.js +0 -22
- package/dist/targets/js/utils/offset.es.js +0 -17
- package/dist/targets/react/animated.cjs.js +0 -126
- package/dist/targets/react/animated.es.js +0 -101
- package/dist/targets/react/context.cjs.js +0 -9
- package/dist/targets/react/context.es.js +0 -5
- package/dist/targets/react/hooks/use-animation.cjs.js +0 -47
- package/dist/targets/react/hooks/use-animation.es.js +0 -43
- package/dist/targets/react/hooks/use-exit.cjs.js +0 -27
- package/dist/targets/react/hooks/use-exit.es.js +0 -23
- package/dist/targets/react/hooks/use-gesture-state.cjs.js +0 -17
- package/dist/targets/react/hooks/use-gesture-state.es.js +0 -13
- package/dist/targets/react/hooks/use-hover.cjs.js +0 -24
- package/dist/targets/react/hooks/use-hover.es.js +0 -20
- package/dist/targets/react/hooks/use-press.cjs.js +0 -25
- package/dist/targets/react/hooks/use-press.es.js +0 -21
- package/dist/targets/react/hooks/use-viewport.cjs.js +0 -37
- package/dist/targets/react/hooks/use-viewport.es.js +0 -33
- package/dist/targets/react/index.cjs.js +0 -17
- package/dist/targets/react/index.es.js +0 -13
- package/dist/targets/react/utils/has-changed.cjs.js +0 -24
- package/dist/targets/react/utils/has-changed.es.js +0 -19
- package/dist/targets/react/utils/keyframes.cjs.js +0 -38
- package/dist/targets/react/utils/keyframes.es.js +0 -34
- package/dist/targets/react/utils/poses.cjs.js +0 -14
- package/dist/targets/react/utils/poses.es.js +0 -10
- package/dist/targets/react/utils/update-target.cjs.js +0 -20
- package/dist/targets/react/utils/update-target.es.js +0 -16
- package/dist/utils/array.cjs.js +0 -14
- package/dist/utils/array.es.js +0 -9
- package/dist/utils/clamp.cjs.js +0 -7
- package/dist/utils/clamp.es.js +0 -3
- package/dist/utils/is-number.cjs.js +0 -7
- package/dist/utils/is-number.es.js +0 -3
- package/dist/utils/mix.cjs.js +0 -28
- package/dist/utils/mix.es.js +0 -24
- package/dist/utils/noop.cjs.js +0 -9
- package/dist/utils/noop.es.js +0 -4
- package/dist/utils/progress.cjs.js +0 -20
- package/dist/utils/progress.es.js +0 -16
- package/dist/utils/stagger.cjs.js +0 -38
- package/dist/utils/stagger.es.js +0 -32
- package/dist/utils/velocity-per-second.cjs.js +0 -15
- package/dist/utils/velocity-per-second.es.js +0 -11
- package/dist/utils/wrap.cjs.js +0 -10
- package/dist/utils/wrap.es.js +0 -6
- package/types/react-entry.d.ts +0 -2
- package/types/targets/dom/animate-style.d.ts +0 -2
- package/types/targets/dom/animate.d.ts +0 -2
- package/types/targets/dom/data.d.ts +0 -2
- package/types/targets/dom/style.d.ts +0 -3
- package/types/targets/dom/timeline/index.d.ts +0 -15
- package/types/targets/dom/timeline/types.d.ts +0 -13
- package/types/targets/dom/timeline/utils/calc-time.d.ts +0 -2
- package/types/targets/dom/timeline/utils/edit.d.ts +0 -4
- package/types/targets/dom/timeline/utils/sort.d.ts +0 -2
- package/types/targets/dom/types.d.ts +0 -114
- package/types/targets/dom/utils/apply.d.ts +0 -3
- package/types/targets/dom/utils/controls.d.ts +0 -12
- package/types/targets/dom/utils/css-var.d.ts +0 -3
- package/types/targets/dom/utils/defaults.d.ts +0 -8
- package/types/targets/dom/utils/easing.d.ts +0 -6
- package/types/targets/dom/utils/feature-detection.d.ts +0 -8
- package/types/targets/dom/utils/get-style-name.d.ts +0 -1
- package/types/targets/dom/utils/keyframes.d.ts +0 -3
- package/types/targets/dom/utils/options.d.ts +0 -2
- package/types/targets/dom/utils/resolve-elements.d.ts +0 -4
- package/types/targets/dom/utils/stop-animation.d.ts +0 -6
- package/types/targets/dom/utils/time.d.ts +0 -1
- package/types/targets/dom/utils/transforms.d.ts +0 -20
- package/types/targets/js/NumberAnimation.d.ts +0 -24
- package/types/targets/js/easing/cubic-bezier.d.ts +0 -1
- package/types/targets/js/easing/glide/generator.d.ts +0 -5
- package/types/targets/js/easing/glide/index.d.ts +0 -2
- package/types/targets/js/easing/glide/types.d.ts +0 -14
- package/types/targets/js/easing/spring/generator.d.ts +0 -6
- package/types/targets/js/easing/spring/index.d.ts +0 -2
- package/types/targets/js/easing/spring/types.d.ts +0 -10
- package/types/targets/js/easing/steps.d.ts +0 -3
- package/types/targets/js/easing/utils/create-generator-easing.d.ts +0 -3
- package/types/targets/js/easing/utils/get-function.d.ts +0 -3
- package/types/targets/js/easing/utils/has-reached-target.d.ts +0 -1
- package/types/targets/js/easing/utils/pregenerate-keyframes.d.ts +0 -7
- package/types/targets/js/types.d.ts +0 -12
- package/types/targets/js/utils/get-easing.d.ts +0 -1
- package/types/targets/js/utils/interpolate.d.ts +0 -2
- package/types/targets/js/utils/offset.d.ts +0 -2
- package/types/targets/react/animated.d.ts +0 -3
- package/types/targets/react/context.d.ts +0 -3
- package/types/targets/react/hooks/use-animation.d.ts +0 -4
- package/types/targets/react/hooks/use-exit.d.ts +0 -3
- package/types/targets/react/hooks/use-gesture-state.d.ts +0 -4
- package/types/targets/react/hooks/use-hover.d.ts +0 -4
- package/types/targets/react/hooks/use-press.d.ts +0 -4
- package/types/targets/react/hooks/use-viewport.d.ts +0 -4
- package/types/targets/react/index.d.ts +0 -2
- package/types/targets/react/types.d.ts +0 -108
- package/types/targets/react/utils/has-changed.d.ts +0 -2
- package/types/targets/react/utils/keyframes.d.ts +0 -3
- package/types/targets/react/utils/poses.d.ts +0 -2
- package/types/targets/react/utils/supported-elements.d.ts +0 -8
- package/types/targets/react/utils/update-target.d.ts +0 -3
- package/types/utils/array.d.ts +0 -2
- package/types/utils/clamp.d.ts +0 -1
- package/types/utils/interpolate.d.ts +0 -0
- package/types/utils/is-number.d.ts +0 -1
- package/types/utils/mix.d.ts +0 -1
- package/types/utils/noop.d.ts +0 -2
- package/types/utils/progress.d.ts +0 -1
- package/types/utils/stagger.d.ts +0 -12
- package/types/utils/value-types.d.ts +0 -0
- package/types/utils/velocity-per-second.d.ts +0 -1
- package/types/utils/wrap.d.ts +0 -1
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var pregenerateKeyframes = require('./pregenerate-keyframes.cjs.js');
|
|
6
|
-
|
|
7
|
-
function createGeneratorEasing(createGenerator) {
|
|
8
|
-
const keyframesCache = new WeakMap();
|
|
9
|
-
return (options = {}) => {
|
|
10
|
-
const generatorCache = new Map();
|
|
11
|
-
const getGenerator = (from = 0, to = 100, velocity = 0, isScale = false) => {
|
|
12
|
-
const key = `${from}-${to}-${velocity}-${isScale}`;
|
|
13
|
-
if (!generatorCache.has(key)) {
|
|
14
|
-
generatorCache.set(key, createGenerator(Object.assign({ from,
|
|
15
|
-
to,
|
|
16
|
-
velocity, restSpeed: isScale ? 0.05 : 2, restDistance: isScale ? 0.01 : 0.5 }, options)));
|
|
17
|
-
}
|
|
18
|
-
return generatorCache.get(key);
|
|
19
|
-
};
|
|
20
|
-
const getKeyframes = (generator) => {
|
|
21
|
-
if (!keyframesCache.has(generator)) {
|
|
22
|
-
keyframesCache.set(generator, pregenerateKeyframes.pregenerateKeyframes(generator));
|
|
23
|
-
}
|
|
24
|
-
return keyframesCache.get(generator);
|
|
25
|
-
};
|
|
26
|
-
return {
|
|
27
|
-
createAnimation: (keyframes, getOrigin, canUseGenerator, name, data) => {
|
|
28
|
-
let settings;
|
|
29
|
-
let generator;
|
|
30
|
-
const numKeyframes = keyframes.length;
|
|
31
|
-
let shouldUseGenerator = canUseGenerator &&
|
|
32
|
-
numKeyframes <= 2 &&
|
|
33
|
-
keyframes.every(isNumberOrNull);
|
|
34
|
-
if (shouldUseGenerator) {
|
|
35
|
-
const prevAnimationState = name && data && data.prevGeneratorState[name];
|
|
36
|
-
const velocity = prevAnimationState &&
|
|
37
|
-
(numKeyframes === 1 ||
|
|
38
|
-
(numKeyframes === 2 && keyframes[0] === null))
|
|
39
|
-
? prevAnimationState.velocity
|
|
40
|
-
: 0;
|
|
41
|
-
const target = keyframes[numKeyframes - 1];
|
|
42
|
-
const unresolvedOrigin = numKeyframes === 1 ? null : keyframes[0];
|
|
43
|
-
const origin = unresolvedOrigin === null
|
|
44
|
-
? prevAnimationState
|
|
45
|
-
? prevAnimationState.value
|
|
46
|
-
: parseFloat(getOrigin())
|
|
47
|
-
: unresolvedOrigin;
|
|
48
|
-
generator = getGenerator(origin, target, velocity, name === null || name === void 0 ? void 0 : name.includes("scale"));
|
|
49
|
-
const keyframesMetadata = getKeyframes(generator);
|
|
50
|
-
settings = Object.assign(Object.assign({}, keyframesMetadata), { easing: "linear" });
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
generator = getGenerator(0, 100);
|
|
54
|
-
const keyframesMetadata = getKeyframes(generator);
|
|
55
|
-
settings = {
|
|
56
|
-
easing: "ease",
|
|
57
|
-
duration: keyframesMetadata.overshootDuration,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// TODO Add test for this
|
|
61
|
-
if (generator && data && name) {
|
|
62
|
-
data.generators[name] = generator;
|
|
63
|
-
}
|
|
64
|
-
return settings;
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const isNumberOrNull = (value) => typeof value !== "string";
|
|
70
|
-
|
|
71
|
-
exports.createGeneratorEasing = createGeneratorEasing;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { pregenerateKeyframes } from './pregenerate-keyframes.es.js';
|
|
2
|
-
|
|
3
|
-
function createGeneratorEasing(createGenerator) {
|
|
4
|
-
const keyframesCache = new WeakMap();
|
|
5
|
-
return (options = {}) => {
|
|
6
|
-
const generatorCache = new Map();
|
|
7
|
-
const getGenerator = (from = 0, to = 100, velocity = 0, isScale = false) => {
|
|
8
|
-
const key = `${from}-${to}-${velocity}-${isScale}`;
|
|
9
|
-
if (!generatorCache.has(key)) {
|
|
10
|
-
generatorCache.set(key, createGenerator(Object.assign({ from,
|
|
11
|
-
to,
|
|
12
|
-
velocity, restSpeed: isScale ? 0.05 : 2, restDistance: isScale ? 0.01 : 0.5 }, options)));
|
|
13
|
-
}
|
|
14
|
-
return generatorCache.get(key);
|
|
15
|
-
};
|
|
16
|
-
const getKeyframes = (generator) => {
|
|
17
|
-
if (!keyframesCache.has(generator)) {
|
|
18
|
-
keyframesCache.set(generator, pregenerateKeyframes(generator));
|
|
19
|
-
}
|
|
20
|
-
return keyframesCache.get(generator);
|
|
21
|
-
};
|
|
22
|
-
return {
|
|
23
|
-
createAnimation: (keyframes, getOrigin, canUseGenerator, name, data) => {
|
|
24
|
-
let settings;
|
|
25
|
-
let generator;
|
|
26
|
-
const numKeyframes = keyframes.length;
|
|
27
|
-
let shouldUseGenerator = canUseGenerator &&
|
|
28
|
-
numKeyframes <= 2 &&
|
|
29
|
-
keyframes.every(isNumberOrNull);
|
|
30
|
-
if (shouldUseGenerator) {
|
|
31
|
-
const prevAnimationState = name && data && data.prevGeneratorState[name];
|
|
32
|
-
const velocity = prevAnimationState &&
|
|
33
|
-
(numKeyframes === 1 ||
|
|
34
|
-
(numKeyframes === 2 && keyframes[0] === null))
|
|
35
|
-
? prevAnimationState.velocity
|
|
36
|
-
: 0;
|
|
37
|
-
const target = keyframes[numKeyframes - 1];
|
|
38
|
-
const unresolvedOrigin = numKeyframes === 1 ? null : keyframes[0];
|
|
39
|
-
const origin = unresolvedOrigin === null
|
|
40
|
-
? prevAnimationState
|
|
41
|
-
? prevAnimationState.value
|
|
42
|
-
: parseFloat(getOrigin())
|
|
43
|
-
: unresolvedOrigin;
|
|
44
|
-
generator = getGenerator(origin, target, velocity, name === null || name === void 0 ? void 0 : name.includes("scale"));
|
|
45
|
-
const keyframesMetadata = getKeyframes(generator);
|
|
46
|
-
settings = Object.assign(Object.assign({}, keyframesMetadata), { easing: "linear" });
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
generator = getGenerator(0, 100);
|
|
50
|
-
const keyframesMetadata = getKeyframes(generator);
|
|
51
|
-
settings = {
|
|
52
|
-
easing: "ease",
|
|
53
|
-
duration: keyframesMetadata.overshootDuration,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
// TODO Add test for this
|
|
57
|
-
if (generator && data && name) {
|
|
58
|
-
data.generators[name] = generator;
|
|
59
|
-
}
|
|
60
|
-
return settings;
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const isNumberOrNull = (value) => typeof value !== "string";
|
|
66
|
-
|
|
67
|
-
export { createGeneratorEasing };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var cubicBezier = require('../cubic-bezier.cjs.js');
|
|
6
|
-
var steps = require('../steps.cjs.js');
|
|
7
|
-
var noop = require('../../../../utils/noop.cjs.js');
|
|
8
|
-
|
|
9
|
-
const namedEasings = {
|
|
10
|
-
ease: cubicBezier.cubicBezier(0.25, 0.1, 0.25, 1.0),
|
|
11
|
-
"ease-in": cubicBezier.cubicBezier(0.42, 0.0, 1.0, 1.0),
|
|
12
|
-
"ease-in-out": cubicBezier.cubicBezier(0.42, 0.0, 0.58, 1.0),
|
|
13
|
-
"ease-out": cubicBezier.cubicBezier(0.0, 0.0, 0.58, 1.0),
|
|
14
|
-
};
|
|
15
|
-
const functionArgsRegex = /\((.*?)\)/;
|
|
16
|
-
function getEasingFunction(definition) {
|
|
17
|
-
// If already an easing function, return
|
|
18
|
-
if (typeof definition === "function")
|
|
19
|
-
return definition;
|
|
20
|
-
// If an easing curve definition, return bezier function
|
|
21
|
-
if (Array.isArray(definition))
|
|
22
|
-
return cubicBezier.cubicBezier(...definition);
|
|
23
|
-
// If we have a predefined easing function, return
|
|
24
|
-
if (namedEasings[definition])
|
|
25
|
-
return namedEasings[definition];
|
|
26
|
-
// If this is a steps function, attempt to create easing curve
|
|
27
|
-
if (definition.startsWith("steps")) {
|
|
28
|
-
const args = functionArgsRegex.exec(definition);
|
|
29
|
-
if (args) {
|
|
30
|
-
const argsArray = args[1].split(",");
|
|
31
|
-
return steps.steps(parseFloat(argsArray[0]), argsArray[1].trim());
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return noop.noopReturn;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.getEasingFunction = getEasingFunction;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { cubicBezier } from '../cubic-bezier.es.js';
|
|
2
|
-
import { steps } from '../steps.es.js';
|
|
3
|
-
import { noopReturn } from '../../../../utils/noop.es.js';
|
|
4
|
-
|
|
5
|
-
const namedEasings = {
|
|
6
|
-
ease: cubicBezier(0.25, 0.1, 0.25, 1.0),
|
|
7
|
-
"ease-in": cubicBezier(0.42, 0.0, 1.0, 1.0),
|
|
8
|
-
"ease-in-out": cubicBezier(0.42, 0.0, 0.58, 1.0),
|
|
9
|
-
"ease-out": cubicBezier(0.0, 0.0, 0.58, 1.0),
|
|
10
|
-
};
|
|
11
|
-
const functionArgsRegex = /\((.*?)\)/;
|
|
12
|
-
function getEasingFunction(definition) {
|
|
13
|
-
// If already an easing function, return
|
|
14
|
-
if (typeof definition === "function")
|
|
15
|
-
return definition;
|
|
16
|
-
// If an easing curve definition, return bezier function
|
|
17
|
-
if (Array.isArray(definition))
|
|
18
|
-
return cubicBezier(...definition);
|
|
19
|
-
// If we have a predefined easing function, return
|
|
20
|
-
if (namedEasings[definition])
|
|
21
|
-
return namedEasings[definition];
|
|
22
|
-
// If this is a steps function, attempt to create easing curve
|
|
23
|
-
if (definition.startsWith("steps")) {
|
|
24
|
-
const args = functionArgsRegex.exec(definition);
|
|
25
|
-
if (args) {
|
|
26
|
-
const argsArray = args[1].split(",");
|
|
27
|
-
return steps(parseFloat(argsArray[0]), argsArray[1].trim());
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return noopReturn;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export { getEasingFunction };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function hasReachedTarget(origin, target, current) {
|
|
6
|
-
return ((origin < target && current >= target) ||
|
|
7
|
-
(origin > target && current <= target));
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
exports.hasReachedTarget = hasReachedTarget;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const timeStep = 10;
|
|
6
|
-
const maxDuration = 10000;
|
|
7
|
-
function pregenerateKeyframes(generator) {
|
|
8
|
-
let overshootDuration = undefined;
|
|
9
|
-
let timestamp = timeStep;
|
|
10
|
-
let state = generator.next(0);
|
|
11
|
-
const keyframes = [state.value];
|
|
12
|
-
while (!state.done && timestamp < maxDuration) {
|
|
13
|
-
state = generator.next(timestamp);
|
|
14
|
-
keyframes.push(state.done ? state.target : state.value);
|
|
15
|
-
if (overshootDuration === undefined && state.hasReachedTarget) {
|
|
16
|
-
overshootDuration = timestamp;
|
|
17
|
-
}
|
|
18
|
-
timestamp += timeStep;
|
|
19
|
-
}
|
|
20
|
-
const duration = timestamp - timeStep;
|
|
21
|
-
/**
|
|
22
|
-
* If generating an animation that didn't actually move,
|
|
23
|
-
* generate a second keyframe so we have an origin and target.
|
|
24
|
-
*/
|
|
25
|
-
if (keyframes.length === 1)
|
|
26
|
-
keyframes.push(state.value);
|
|
27
|
-
return {
|
|
28
|
-
keyframes,
|
|
29
|
-
duration: duration / 1000,
|
|
30
|
-
overshootDuration: (overshootDuration !== null && overshootDuration !== void 0 ? overshootDuration : duration) / 1000,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
exports.pregenerateKeyframes = pregenerateKeyframes;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const timeStep = 10;
|
|
2
|
-
const maxDuration = 10000;
|
|
3
|
-
function pregenerateKeyframes(generator) {
|
|
4
|
-
let overshootDuration = undefined;
|
|
5
|
-
let timestamp = timeStep;
|
|
6
|
-
let state = generator.next(0);
|
|
7
|
-
const keyframes = [state.value];
|
|
8
|
-
while (!state.done && timestamp < maxDuration) {
|
|
9
|
-
state = generator.next(timestamp);
|
|
10
|
-
keyframes.push(state.done ? state.target : state.value);
|
|
11
|
-
if (overshootDuration === undefined && state.hasReachedTarget) {
|
|
12
|
-
overshootDuration = timestamp;
|
|
13
|
-
}
|
|
14
|
-
timestamp += timeStep;
|
|
15
|
-
}
|
|
16
|
-
const duration = timestamp - timeStep;
|
|
17
|
-
/**
|
|
18
|
-
* If generating an animation that didn't actually move,
|
|
19
|
-
* generate a second keyframe so we have an origin and target.
|
|
20
|
-
*/
|
|
21
|
-
if (keyframes.length === 1)
|
|
22
|
-
keyframes.push(state.value);
|
|
23
|
-
return {
|
|
24
|
-
keyframes,
|
|
25
|
-
duration: duration / 1000,
|
|
26
|
-
overshootDuration: (overshootDuration !== null && overshootDuration !== void 0 ? overshootDuration : duration) / 1000,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { pregenerateKeyframes };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var wrap = require('../../../utils/wrap.cjs.js');
|
|
6
|
-
var easing = require('../../dom/utils/easing.cjs.js');
|
|
7
|
-
|
|
8
|
-
function getEasingForSegment(easing$1, i) {
|
|
9
|
-
return easing.isEasingList(easing$1)
|
|
10
|
-
? easing$1[wrap.wrap(0, easing$1.length, i)]
|
|
11
|
-
: easing$1;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
exports.getEasingForSegment = getEasingForSegment;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { wrap } from '../../../utils/wrap.es.js';
|
|
2
|
-
import { isEasingList } from '../../dom/utils/easing.es.js';
|
|
3
|
-
|
|
4
|
-
function getEasingForSegment(easing, i) {
|
|
5
|
-
return isEasingList(easing)
|
|
6
|
-
? easing[wrap(0, easing.length, i)]
|
|
7
|
-
: easing;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { getEasingForSegment };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var mix = require('../../../utils/mix.cjs.js');
|
|
6
|
-
var noop = require('../../../utils/noop.cjs.js');
|
|
7
|
-
var progress = require('../../../utils/progress.cjs.js');
|
|
8
|
-
var getEasing = require('./get-easing.cjs.js');
|
|
9
|
-
var offset = require('./offset.cjs.js');
|
|
10
|
-
|
|
11
|
-
const clampProgress = (p) => Math.min(1, Math.max(p, 0));
|
|
12
|
-
function slowInterpolateNumbers(output, input = offset.defaultOffset(output.length), easing = noop.noopReturn) {
|
|
13
|
-
const length = output.length;
|
|
14
|
-
/**
|
|
15
|
-
* If the input length is lower than the output we
|
|
16
|
-
* fill the input to match. This currently assumes the input
|
|
17
|
-
* is an animation progress value so is a good candidate for
|
|
18
|
-
* moving outside the function.
|
|
19
|
-
*/
|
|
20
|
-
const remainder = length - input.length;
|
|
21
|
-
remainder > 0 && offset.fillOffset(input, remainder);
|
|
22
|
-
return (t) => {
|
|
23
|
-
let i = 0;
|
|
24
|
-
for (; i < length - 2; i++) {
|
|
25
|
-
if (t < input[i + 1])
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
let progressInRange = clampProgress(progress.progress(input[i], input[i + 1], t));
|
|
29
|
-
const segmentEasing = getEasing.getEasingForSegment(easing, i);
|
|
30
|
-
progressInRange = segmentEasing(progressInRange);
|
|
31
|
-
return mix.mix(output[i], output[i + 1], progressInRange);
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.slowInterpolateNumbers = slowInterpolateNumbers;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { mix } from '../../../utils/mix.es.js';
|
|
2
|
-
import { noopReturn } from '../../../utils/noop.es.js';
|
|
3
|
-
import { progress } from '../../../utils/progress.es.js';
|
|
4
|
-
import { getEasingForSegment } from './get-easing.es.js';
|
|
5
|
-
import { defaultOffset, fillOffset } from './offset.es.js';
|
|
6
|
-
|
|
7
|
-
const clampProgress = (p) => Math.min(1, Math.max(p, 0));
|
|
8
|
-
function slowInterpolateNumbers(output, input = defaultOffset(output.length), easing = noopReturn) {
|
|
9
|
-
const length = output.length;
|
|
10
|
-
/**
|
|
11
|
-
* If the input length is lower than the output we
|
|
12
|
-
* fill the input to match. This currently assumes the input
|
|
13
|
-
* is an animation progress value so is a good candidate for
|
|
14
|
-
* moving outside the function.
|
|
15
|
-
*/
|
|
16
|
-
const remainder = length - input.length;
|
|
17
|
-
remainder > 0 && fillOffset(input, remainder);
|
|
18
|
-
return (t) => {
|
|
19
|
-
let i = 0;
|
|
20
|
-
for (; i < length - 2; i++) {
|
|
21
|
-
if (t < input[i + 1])
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
let progressInRange = clampProgress(progress(input[i], input[i + 1], t));
|
|
25
|
-
const segmentEasing = getEasingForSegment(easing, i);
|
|
26
|
-
progressInRange = segmentEasing(progressInRange);
|
|
27
|
-
return mix(output[i], output[i + 1], progressInRange);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { slowInterpolateNumbers };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var mix = require('../../../utils/mix.cjs.js');
|
|
6
|
-
var progress = require('../../../utils/progress.cjs.js');
|
|
7
|
-
|
|
8
|
-
function fillOffset(offset, remaining) {
|
|
9
|
-
const min = offset[offset.length - 1];
|
|
10
|
-
for (let i = 1; i <= remaining; i++) {
|
|
11
|
-
const offsetProgress = progress.progress(0, remaining, i);
|
|
12
|
-
offset.push(mix.mix(min, 1, offsetProgress));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function defaultOffset(length) {
|
|
16
|
-
const offset = [0];
|
|
17
|
-
fillOffset(offset, length - 1);
|
|
18
|
-
return offset;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.defaultOffset = defaultOffset;
|
|
22
|
-
exports.fillOffset = fillOffset;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { mix } from '../../../utils/mix.es.js';
|
|
2
|
-
import { progress } from '../../../utils/progress.es.js';
|
|
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
|
-
function defaultOffset(length) {
|
|
12
|
-
const offset = [0];
|
|
13
|
-
fillOffset(offset, length - 1);
|
|
14
|
-
return offset;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { defaultOffset, fillOffset };
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tslib = require('tslib');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var useAnimation = require('./hooks/use-animation.cjs.js');
|
|
8
|
-
var useHover = require('./hooks/use-hover.cjs.js');
|
|
9
|
-
var usePress = require('./hooks/use-press.cjs.js');
|
|
10
|
-
var useExit = require('./hooks/use-exit.cjs.js');
|
|
11
|
-
var useViewport = require('./hooks/use-viewport.cjs.js');
|
|
12
|
-
var keyframes = require('./utils/keyframes.cjs.js');
|
|
13
|
-
var poses = require('./utils/poses.cjs.js');
|
|
14
|
-
var context = require('./context.cjs.js');
|
|
15
|
-
|
|
16
|
-
function _interopNamespace(e) {
|
|
17
|
-
if (e && e.__esModule) return e;
|
|
18
|
-
var n = Object.create(null);
|
|
19
|
-
if (e) {
|
|
20
|
-
Object.keys(e).forEach(function (k) {
|
|
21
|
-
if (k !== 'default') {
|
|
22
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function () {
|
|
26
|
-
return e[k];
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
n['default'] = e;
|
|
33
|
-
return Object.freeze(n);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
37
|
-
|
|
38
|
-
function createAnimatedComponent(Component) {
|
|
39
|
-
function Animated(props, _externalRef) {
|
|
40
|
-
// TODO: Support externalRef if provided
|
|
41
|
-
const ref = React.useRef(null);
|
|
42
|
-
const { options: defaultOptions, style, initial, hover, press, exit, inViewport, viewport, poses: poses$1, onStart, onComplete, onViewportEnter, onViewportLeave, inherit = true } = props, forwardProps = tslib.__rest(props
|
|
43
|
-
/**
|
|
44
|
-
* Track throughout the render which poses are considered active and should
|
|
45
|
-
* be passed to children.
|
|
46
|
-
*/
|
|
47
|
-
, ["options", "style", "initial", "hover", "press", "exit", "inViewport", "viewport", "poses", "onStart", "onComplete", "onViewportEnter", "onViewportLeave", "inherit"]);
|
|
48
|
-
/**
|
|
49
|
-
* Track throughout the render which poses are considered active and should
|
|
50
|
-
* be passed to children.
|
|
51
|
-
*/
|
|
52
|
-
const isPoseActive = { initial: true, style: true };
|
|
53
|
-
/**
|
|
54
|
-
* Inherit poses from the parent context,
|
|
55
|
-
*/
|
|
56
|
-
let inherited = React.useContext(context.AnimationContext);
|
|
57
|
-
if (!inherit)
|
|
58
|
-
inherited = {};
|
|
59
|
-
const resolvedStyle = poses.resolvePose(style, inherited.style, poses$1);
|
|
60
|
-
const resolvedInitial = poses.resolvePose(initial, inherited.initial, poses$1);
|
|
61
|
-
const initialTarget = Object.assign(Object.assign({}, resolvedStyle), resolvedInitial);
|
|
62
|
-
const target = Object.assign(Object.assign({}, resolvedInitial), resolvedStyle);
|
|
63
|
-
const options = Object.assign(Object.assign({}, defaultOptions), resolvedStyle === null || resolvedStyle === void 0 ? void 0 : resolvedStyle.options);
|
|
64
|
-
/**
|
|
65
|
-
* If we haven't created a style prop for SSR yet (this is the initial render)
|
|
66
|
-
* make one. We provide this to React every render as beyond that with manage style
|
|
67
|
-
* via animations.
|
|
68
|
-
*/
|
|
69
|
-
const styleProp = React.useRef(null);
|
|
70
|
-
styleProp.current || (styleProp.current = keyframes.convertKeyframesToStyles(initialTarget));
|
|
71
|
-
/**
|
|
72
|
-
* Attach animation event handlers (gestures/exit/viewport appearance).
|
|
73
|
-
* This are called in reverse order of which styles should take priority when
|
|
74
|
-
* active, for example if there's a hover and press gesture active the press
|
|
75
|
-
* gesture will take precedence.
|
|
76
|
-
*/
|
|
77
|
-
const hoverProps = useHover.useHover(target, options, props, inherited, isPoseActive);
|
|
78
|
-
const pressProps = usePress.usePress(target, options, props, inherited, isPoseActive);
|
|
79
|
-
useViewport.useViewport(ref, target, options, props, inherited, isPoseActive);
|
|
80
|
-
const onExitComplete = useExit.useExit(target, options, props, inherited);
|
|
81
|
-
/**
|
|
82
|
-
* Compare our final calculated style target with the one from the previous render
|
|
83
|
-
* and trigger any necessary animations.
|
|
84
|
-
*/
|
|
85
|
-
useAnimation.useAnimation(ref, initialTarget, target, options, onStart, (animation) => {
|
|
86
|
-
onComplete && onComplete(animation);
|
|
87
|
-
onExitComplete && onExitComplete();
|
|
88
|
-
});
|
|
89
|
-
const element = React.createElement(Component, Object.assign({}, forwardProps, hoverProps, pressProps, {
|
|
90
|
-
style: styleProp.current,
|
|
91
|
-
ref,
|
|
92
|
-
}));
|
|
93
|
-
/**
|
|
94
|
-
* Create a variant context to pass forward to child components.
|
|
95
|
-
*/
|
|
96
|
-
const context$1 = variantProps.reduce((acc, key) => {
|
|
97
|
-
acc[key] = undefined;
|
|
98
|
-
if (props[key]) {
|
|
99
|
-
if (typeof props[key] === "string" && isPoseActive[key]) {
|
|
100
|
-
acc[key] = props[key];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
else if (inherited[key]) {
|
|
104
|
-
acc[key] = inherited[key];
|
|
105
|
-
}
|
|
106
|
-
return acc;
|
|
107
|
-
}, {});
|
|
108
|
-
/**
|
|
109
|
-
* Memoize the context so we only trigger a re-render in children if the values
|
|
110
|
-
* within it change.
|
|
111
|
-
*/
|
|
112
|
-
const memoizedContext = React.useMemo(() => context$1, Object.values(context$1));
|
|
113
|
-
return (React__namespace.createElement(context.AnimationContext.Provider, { value: memoizedContext }, element));
|
|
114
|
-
}
|
|
115
|
-
return React.forwardRef(Animated);
|
|
116
|
-
}
|
|
117
|
-
const variantProps = [
|
|
118
|
-
"initial",
|
|
119
|
-
"style",
|
|
120
|
-
"hover",
|
|
121
|
-
"press",
|
|
122
|
-
"inViewport",
|
|
123
|
-
"exit",
|
|
124
|
-
];
|
|
125
|
-
|
|
126
|
-
exports.createAnimatedComponent = createAnimatedComponent;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { __rest } from 'tslib';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { forwardRef, useRef, useContext, createElement, useMemo } from 'react';
|
|
4
|
-
import { useAnimation } from './hooks/use-animation.es.js';
|
|
5
|
-
import { useHover } from './hooks/use-hover.es.js';
|
|
6
|
-
import { usePress } from './hooks/use-press.es.js';
|
|
7
|
-
import { useExit } from './hooks/use-exit.es.js';
|
|
8
|
-
import { useViewport } from './hooks/use-viewport.es.js';
|
|
9
|
-
import { convertKeyframesToStyles } from './utils/keyframes.es.js';
|
|
10
|
-
import { resolvePose } from './utils/poses.es.js';
|
|
11
|
-
import { AnimationContext } from './context.es.js';
|
|
12
|
-
|
|
13
|
-
function createAnimatedComponent(Component) {
|
|
14
|
-
function Animated(props, _externalRef) {
|
|
15
|
-
// TODO: Support externalRef if provided
|
|
16
|
-
const ref = useRef(null);
|
|
17
|
-
const { options: defaultOptions, style, initial, hover, press, exit, inViewport, viewport, poses, onStart, onComplete, onViewportEnter, onViewportLeave, inherit = true } = props, forwardProps = __rest(props
|
|
18
|
-
/**
|
|
19
|
-
* Track throughout the render which poses are considered active and should
|
|
20
|
-
* be passed to children.
|
|
21
|
-
*/
|
|
22
|
-
, ["options", "style", "initial", "hover", "press", "exit", "inViewport", "viewport", "poses", "onStart", "onComplete", "onViewportEnter", "onViewportLeave", "inherit"]);
|
|
23
|
-
/**
|
|
24
|
-
* Track throughout the render which poses are considered active and should
|
|
25
|
-
* be passed to children.
|
|
26
|
-
*/
|
|
27
|
-
const isPoseActive = { initial: true, style: true };
|
|
28
|
-
/**
|
|
29
|
-
* Inherit poses from the parent context,
|
|
30
|
-
*/
|
|
31
|
-
let inherited = useContext(AnimationContext);
|
|
32
|
-
if (!inherit)
|
|
33
|
-
inherited = {};
|
|
34
|
-
const resolvedStyle = resolvePose(style, inherited.style, poses);
|
|
35
|
-
const resolvedInitial = resolvePose(initial, inherited.initial, poses);
|
|
36
|
-
const initialTarget = Object.assign(Object.assign({}, resolvedStyle), resolvedInitial);
|
|
37
|
-
const target = Object.assign(Object.assign({}, resolvedInitial), resolvedStyle);
|
|
38
|
-
const options = Object.assign(Object.assign({}, defaultOptions), resolvedStyle === null || resolvedStyle === void 0 ? void 0 : resolvedStyle.options);
|
|
39
|
-
/**
|
|
40
|
-
* If we haven't created a style prop for SSR yet (this is the initial render)
|
|
41
|
-
* make one. We provide this to React every render as beyond that with manage style
|
|
42
|
-
* via animations.
|
|
43
|
-
*/
|
|
44
|
-
const styleProp = useRef(null);
|
|
45
|
-
styleProp.current || (styleProp.current = convertKeyframesToStyles(initialTarget));
|
|
46
|
-
/**
|
|
47
|
-
* Attach animation event handlers (gestures/exit/viewport appearance).
|
|
48
|
-
* This are called in reverse order of which styles should take priority when
|
|
49
|
-
* active, for example if there's a hover and press gesture active the press
|
|
50
|
-
* gesture will take precedence.
|
|
51
|
-
*/
|
|
52
|
-
const hoverProps = useHover(target, options, props, inherited, isPoseActive);
|
|
53
|
-
const pressProps = usePress(target, options, props, inherited, isPoseActive);
|
|
54
|
-
useViewport(ref, target, options, props, inherited, isPoseActive);
|
|
55
|
-
const onExitComplete = useExit(target, options, props, inherited);
|
|
56
|
-
/**
|
|
57
|
-
* Compare our final calculated style target with the one from the previous render
|
|
58
|
-
* and trigger any necessary animations.
|
|
59
|
-
*/
|
|
60
|
-
useAnimation(ref, initialTarget, target, options, onStart, (animation) => {
|
|
61
|
-
onComplete && onComplete(animation);
|
|
62
|
-
onExitComplete && onExitComplete();
|
|
63
|
-
});
|
|
64
|
-
const element = createElement(Component, Object.assign({}, forwardProps, hoverProps, pressProps, {
|
|
65
|
-
style: styleProp.current,
|
|
66
|
-
ref,
|
|
67
|
-
}));
|
|
68
|
-
/**
|
|
69
|
-
* Create a variant context to pass forward to child components.
|
|
70
|
-
*/
|
|
71
|
-
const context = variantProps.reduce((acc, key) => {
|
|
72
|
-
acc[key] = undefined;
|
|
73
|
-
if (props[key]) {
|
|
74
|
-
if (typeof props[key] === "string" && isPoseActive[key]) {
|
|
75
|
-
acc[key] = props[key];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else if (inherited[key]) {
|
|
79
|
-
acc[key] = inherited[key];
|
|
80
|
-
}
|
|
81
|
-
return acc;
|
|
82
|
-
}, {});
|
|
83
|
-
/**
|
|
84
|
-
* Memoize the context so we only trigger a re-render in children if the values
|
|
85
|
-
* within it change.
|
|
86
|
-
*/
|
|
87
|
-
const memoizedContext = useMemo(() => context, Object.values(context));
|
|
88
|
-
return (React.createElement(AnimationContext.Provider, { value: memoizedContext }, element));
|
|
89
|
-
}
|
|
90
|
-
return forwardRef(Animated);
|
|
91
|
-
}
|
|
92
|
-
const variantProps = [
|
|
93
|
-
"initial",
|
|
94
|
-
"style",
|
|
95
|
-
"hover",
|
|
96
|
-
"press",
|
|
97
|
-
"inViewport",
|
|
98
|
-
"exit",
|
|
99
|
-
];
|
|
100
|
-
|
|
101
|
-
export { createAnimatedComponent };
|