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.
Files changed (210) hide show
  1. package/README.md +0 -19
  2. package/dist/main.cjs.js +11 -13
  3. package/dist/main.es.js +7 -6
  4. package/dist/motion.min.js +1 -1
  5. package/dist/motion.umd.js +412 -16
  6. package/dist/react.cjs.js +7 -2
  7. package/dist/react.es.js +1 -1
  8. package/dist/size-index.js +1 -0
  9. package/lib/index.js +5 -0
  10. package/lib/index.js.map +1 -0
  11. package/lib/react.js +2 -0
  12. package/lib/react.js.map +1 -0
  13. package/lib/vue.js +2 -0
  14. package/lib/vue.js.map +1 -0
  15. package/package.json +16 -134
  16. package/react/package.json +1 -1
  17. package/types/index.d.ts +3 -7
  18. package/types/index.d.ts.map +1 -0
  19. package/types/react.d.ts +2 -0
  20. package/types/react.d.ts.map +1 -0
  21. package/types/vue.d.ts +2 -0
  22. package/types/vue.d.ts.map +1 -0
  23. package/CHANGELOG.md +0 -97
  24. package/dist/size-animate-dom.js +0 -1
  25. package/dist/size-animate-style.js +0 -1
  26. package/dist/size-react.js +0 -1
  27. package/dist/size-spring.js +0 -1
  28. package/dist/size-timeline-dom.js +0 -1
  29. package/dist/size-webpack-animate.js +0 -1
  30. package/dist/targets/dom/animate-style.cjs.js +0 -182
  31. package/dist/targets/dom/animate-style.es.js +0 -178
  32. package/dist/targets/dom/animate.cjs.js +0 -42
  33. package/dist/targets/dom/animate.es.js +0 -38
  34. package/dist/targets/dom/data.cjs.js +0 -18
  35. package/dist/targets/dom/data.es.js +0 -14
  36. package/dist/targets/dom/style.cjs.js +0 -22
  37. package/dist/targets/dom/style.es.js +0 -18
  38. package/dist/targets/dom/timeline/index.cjs.js +0 -174
  39. package/dist/targets/dom/timeline/index.es.js +0 -169
  40. package/dist/targets/dom/timeline/utils/calc-time.cjs.js +0 -23
  41. package/dist/targets/dom/timeline/utils/calc-time.es.js +0 -19
  42. package/dist/targets/dom/timeline/utils/edit.cjs.js +0 -36
  43. package/dist/targets/dom/timeline/utils/edit.es.js +0 -31
  44. package/dist/targets/dom/timeline/utils/sort.cjs.js +0 -14
  45. package/dist/targets/dom/timeline/utils/sort.es.js +0 -10
  46. package/dist/targets/dom/utils/apply.cjs.js +0 -9
  47. package/dist/targets/dom/utils/apply.es.js +0 -4
  48. package/dist/targets/dom/utils/controls.cjs.js +0 -59
  49. package/dist/targets/dom/utils/controls.es.js +0 -54
  50. package/dist/targets/dom/utils/css-var.cjs.js +0 -29
  51. package/dist/targets/dom/utils/css-var.es.js +0 -23
  52. package/dist/targets/dom/utils/defaults.cjs.js +0 -13
  53. package/dist/targets/dom/utils/defaults.es.js +0 -9
  54. package/dist/targets/dom/utils/easing.cjs.js +0 -18
  55. package/dist/targets/dom/utils/easing.es.js +0 -10
  56. package/dist/targets/dom/utils/feature-detection.cjs.js +0 -31
  57. package/dist/targets/dom/utils/feature-detection.es.js +0 -27
  58. package/dist/targets/dom/utils/get-style-name.cjs.js +0 -13
  59. package/dist/targets/dom/utils/get-style-name.es.js +0 -9
  60. package/dist/targets/dom/utils/keyframes.cjs.js +0 -16
  61. package/dist/targets/dom/utils/keyframes.es.js +0 -11
  62. package/dist/targets/dom/utils/options.cjs.js +0 -13
  63. package/dist/targets/dom/utils/options.es.js +0 -9
  64. package/dist/targets/dom/utils/resolve-elements.cjs.js +0 -22
  65. package/dist/targets/dom/utils/resolve-elements.es.js +0 -18
  66. package/dist/targets/dom/utils/stop-animation.cjs.js +0 -19
  67. package/dist/targets/dom/utils/stop-animation.es.js +0 -15
  68. package/dist/targets/dom/utils/time.cjs.js +0 -7
  69. package/dist/targets/dom/utils/time.es.js +0 -3
  70. package/dist/targets/dom/utils/transforms.cjs.js +0 -85
  71. package/dist/targets/dom/utils/transforms.es.js +0 -74
  72. package/dist/targets/js/NumberAnimation.cjs.js +0 -144
  73. package/dist/targets/js/NumberAnimation.es.js +0 -140
  74. package/dist/targets/js/easing/cubic-bezier.cjs.js +0 -57
  75. package/dist/targets/js/easing/cubic-bezier.es.js +0 -53
  76. package/dist/targets/js/easing/glide/generator.cjs.js +0 -99
  77. package/dist/targets/js/easing/glide/generator.es.js +0 -95
  78. package/dist/targets/js/easing/glide/index.cjs.js +0 -10
  79. package/dist/targets/js/easing/glide/index.es.js +0 -6
  80. package/dist/targets/js/easing/spring/generator.cjs.js +0 -64
  81. package/dist/targets/js/easing/spring/generator.es.js +0 -57
  82. package/dist/targets/js/easing/spring/index.cjs.js +0 -10
  83. package/dist/targets/js/easing/spring/index.es.js +0 -6
  84. package/dist/targets/js/easing/steps.cjs.js +0 -15
  85. package/dist/targets/js/easing/steps.es.js +0 -11
  86. package/dist/targets/js/easing/utils/create-generator-easing.cjs.js +0 -71
  87. package/dist/targets/js/easing/utils/create-generator-easing.es.js +0 -67
  88. package/dist/targets/js/easing/utils/get-function.cjs.js +0 -37
  89. package/dist/targets/js/easing/utils/get-function.es.js +0 -33
  90. package/dist/targets/js/easing/utils/has-reached-target.cjs.js +0 -10
  91. package/dist/targets/js/easing/utils/has-reached-target.es.js +0 -6
  92. package/dist/targets/js/easing/utils/pregenerate-keyframes.cjs.js +0 -34
  93. package/dist/targets/js/easing/utils/pregenerate-keyframes.es.js +0 -30
  94. package/dist/targets/js/utils/get-easing.cjs.js +0 -14
  95. package/dist/targets/js/utils/get-easing.es.js +0 -10
  96. package/dist/targets/js/utils/interpolate.cjs.js +0 -35
  97. package/dist/targets/js/utils/interpolate.es.js +0 -31
  98. package/dist/targets/js/utils/offset.cjs.js +0 -22
  99. package/dist/targets/js/utils/offset.es.js +0 -17
  100. package/dist/targets/react/animated.cjs.js +0 -126
  101. package/dist/targets/react/animated.es.js +0 -101
  102. package/dist/targets/react/context.cjs.js +0 -9
  103. package/dist/targets/react/context.es.js +0 -5
  104. package/dist/targets/react/hooks/use-animation.cjs.js +0 -47
  105. package/dist/targets/react/hooks/use-animation.es.js +0 -43
  106. package/dist/targets/react/hooks/use-exit.cjs.js +0 -27
  107. package/dist/targets/react/hooks/use-exit.es.js +0 -23
  108. package/dist/targets/react/hooks/use-gesture-state.cjs.js +0 -17
  109. package/dist/targets/react/hooks/use-gesture-state.es.js +0 -13
  110. package/dist/targets/react/hooks/use-hover.cjs.js +0 -24
  111. package/dist/targets/react/hooks/use-hover.es.js +0 -20
  112. package/dist/targets/react/hooks/use-press.cjs.js +0 -25
  113. package/dist/targets/react/hooks/use-press.es.js +0 -21
  114. package/dist/targets/react/hooks/use-viewport.cjs.js +0 -37
  115. package/dist/targets/react/hooks/use-viewport.es.js +0 -33
  116. package/dist/targets/react/index.cjs.js +0 -17
  117. package/dist/targets/react/index.es.js +0 -13
  118. package/dist/targets/react/utils/has-changed.cjs.js +0 -24
  119. package/dist/targets/react/utils/has-changed.es.js +0 -19
  120. package/dist/targets/react/utils/keyframes.cjs.js +0 -38
  121. package/dist/targets/react/utils/keyframes.es.js +0 -34
  122. package/dist/targets/react/utils/poses.cjs.js +0 -14
  123. package/dist/targets/react/utils/poses.es.js +0 -10
  124. package/dist/targets/react/utils/update-target.cjs.js +0 -20
  125. package/dist/targets/react/utils/update-target.es.js +0 -16
  126. package/dist/utils/array.cjs.js +0 -14
  127. package/dist/utils/array.es.js +0 -9
  128. package/dist/utils/clamp.cjs.js +0 -7
  129. package/dist/utils/clamp.es.js +0 -3
  130. package/dist/utils/is-number.cjs.js +0 -7
  131. package/dist/utils/is-number.es.js +0 -3
  132. package/dist/utils/mix.cjs.js +0 -28
  133. package/dist/utils/mix.es.js +0 -24
  134. package/dist/utils/noop.cjs.js +0 -9
  135. package/dist/utils/noop.es.js +0 -4
  136. package/dist/utils/progress.cjs.js +0 -20
  137. package/dist/utils/progress.es.js +0 -16
  138. package/dist/utils/stagger.cjs.js +0 -38
  139. package/dist/utils/stagger.es.js +0 -32
  140. package/dist/utils/velocity-per-second.cjs.js +0 -15
  141. package/dist/utils/velocity-per-second.es.js +0 -11
  142. package/dist/utils/wrap.cjs.js +0 -10
  143. package/dist/utils/wrap.es.js +0 -6
  144. package/types/react-entry.d.ts +0 -2
  145. package/types/targets/dom/animate-style.d.ts +0 -2
  146. package/types/targets/dom/animate.d.ts +0 -2
  147. package/types/targets/dom/data.d.ts +0 -2
  148. package/types/targets/dom/style.d.ts +0 -3
  149. package/types/targets/dom/timeline/index.d.ts +0 -15
  150. package/types/targets/dom/timeline/types.d.ts +0 -13
  151. package/types/targets/dom/timeline/utils/calc-time.d.ts +0 -2
  152. package/types/targets/dom/timeline/utils/edit.d.ts +0 -4
  153. package/types/targets/dom/timeline/utils/sort.d.ts +0 -2
  154. package/types/targets/dom/types.d.ts +0 -114
  155. package/types/targets/dom/utils/apply.d.ts +0 -3
  156. package/types/targets/dom/utils/controls.d.ts +0 -12
  157. package/types/targets/dom/utils/css-var.d.ts +0 -3
  158. package/types/targets/dom/utils/defaults.d.ts +0 -8
  159. package/types/targets/dom/utils/easing.d.ts +0 -6
  160. package/types/targets/dom/utils/feature-detection.d.ts +0 -8
  161. package/types/targets/dom/utils/get-style-name.d.ts +0 -1
  162. package/types/targets/dom/utils/keyframes.d.ts +0 -3
  163. package/types/targets/dom/utils/options.d.ts +0 -2
  164. package/types/targets/dom/utils/resolve-elements.d.ts +0 -4
  165. package/types/targets/dom/utils/stop-animation.d.ts +0 -6
  166. package/types/targets/dom/utils/time.d.ts +0 -1
  167. package/types/targets/dom/utils/transforms.d.ts +0 -20
  168. package/types/targets/js/NumberAnimation.d.ts +0 -24
  169. package/types/targets/js/easing/cubic-bezier.d.ts +0 -1
  170. package/types/targets/js/easing/glide/generator.d.ts +0 -5
  171. package/types/targets/js/easing/glide/index.d.ts +0 -2
  172. package/types/targets/js/easing/glide/types.d.ts +0 -14
  173. package/types/targets/js/easing/spring/generator.d.ts +0 -6
  174. package/types/targets/js/easing/spring/index.d.ts +0 -2
  175. package/types/targets/js/easing/spring/types.d.ts +0 -10
  176. package/types/targets/js/easing/steps.d.ts +0 -3
  177. package/types/targets/js/easing/utils/create-generator-easing.d.ts +0 -3
  178. package/types/targets/js/easing/utils/get-function.d.ts +0 -3
  179. package/types/targets/js/easing/utils/has-reached-target.d.ts +0 -1
  180. package/types/targets/js/easing/utils/pregenerate-keyframes.d.ts +0 -7
  181. package/types/targets/js/types.d.ts +0 -12
  182. package/types/targets/js/utils/get-easing.d.ts +0 -1
  183. package/types/targets/js/utils/interpolate.d.ts +0 -2
  184. package/types/targets/js/utils/offset.d.ts +0 -2
  185. package/types/targets/react/animated.d.ts +0 -3
  186. package/types/targets/react/context.d.ts +0 -3
  187. package/types/targets/react/hooks/use-animation.d.ts +0 -4
  188. package/types/targets/react/hooks/use-exit.d.ts +0 -3
  189. package/types/targets/react/hooks/use-gesture-state.d.ts +0 -4
  190. package/types/targets/react/hooks/use-hover.d.ts +0 -4
  191. package/types/targets/react/hooks/use-press.d.ts +0 -4
  192. package/types/targets/react/hooks/use-viewport.d.ts +0 -4
  193. package/types/targets/react/index.d.ts +0 -2
  194. package/types/targets/react/types.d.ts +0 -108
  195. package/types/targets/react/utils/has-changed.d.ts +0 -2
  196. package/types/targets/react/utils/keyframes.d.ts +0 -3
  197. package/types/targets/react/utils/poses.d.ts +0 -2
  198. package/types/targets/react/utils/supported-elements.d.ts +0 -8
  199. package/types/targets/react/utils/update-target.d.ts +0 -3
  200. package/types/utils/array.d.ts +0 -2
  201. package/types/utils/clamp.d.ts +0 -1
  202. package/types/utils/interpolate.d.ts +0 -0
  203. package/types/utils/is-number.d.ts +0 -1
  204. package/types/utils/mix.d.ts +0 -1
  205. package/types/utils/noop.d.ts +0 -2
  206. package/types/utils/progress.d.ts +0 -1
  207. package/types/utils/stagger.d.ts +0 -12
  208. package/types/utils/value-types.d.ts +0 -0
  209. package/types/utils/velocity-per-second.d.ts +0 -1
  210. package/types/utils/wrap.d.ts +0 -1
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
-
7
- const AnimationContext = React.createContext({});
8
-
9
- exports.AnimationContext = AnimationContext;
@@ -1,5 +0,0 @@
1
- import { createContext } from 'react';
2
-
3
- const AnimationContext = createContext({});
4
-
5
- export { AnimationContext };
@@ -1,47 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
- var animateStyle = require('../../dom/animate-style.cjs.js');
7
- var noop = require('../../../utils/noop.cjs.js');
8
- var hasChanged = require('../utils/has-changed.cjs.js');
9
- var options = require('../../dom/utils/options.cjs.js');
10
-
11
- function useAnimation(ref, initial, target, options$1, onStart, onComplete) {
12
- const prevTarget = React.useRef(initial);
13
- React.useEffect(() => {
14
- const targetKeyframe = {};
15
- const allKeys = new Set([
16
- ...Object.keys(target),
17
- ...Object.keys(prevTarget.current),
18
- ]);
19
- allKeys.forEach((key) => {
20
- let next = target[key];
21
- if (!hasChanged.hasChanged(next, prevTarget.current[key]))
22
- return;
23
- /**
24
- * TODO: If next is undefined, throw error or record a "base value"
25
- * to animate back down to
26
- */
27
- targetKeyframe[key] = next;
28
- });
29
- if (Object.keys(targetKeyframe).length && ref.current) {
30
- onStart === null || onStart === void 0 ? void 0 : onStart(targetKeyframe);
31
- const animationFactories = [];
32
- for (const key in targetKeyframe) {
33
- const animation = animateStyle.animateStyle(ref.current, key, targetKeyframe[key], options.getOptions(options$1, key));
34
- animationFactories.push(animation);
35
- }
36
- const animations = animationFactories
37
- .map((factory) => factory())
38
- .filter(Boolean);
39
- Promise.all(animations.map((animation) => animation.finished))
40
- .then(() => onComplete === null || onComplete === void 0 ? void 0 : onComplete(targetKeyframe))
41
- .catch(noop.noop);
42
- }
43
- prevTarget.current = target;
44
- });
45
- }
46
-
47
- exports.useAnimation = useAnimation;
@@ -1,43 +0,0 @@
1
- import { useRef, useEffect } from 'react';
2
- import { animateStyle } from '../../dom/animate-style.es.js';
3
- import { noop } from '../../../utils/noop.es.js';
4
- import { hasChanged } from '../utils/has-changed.es.js';
5
- import { getOptions } from '../../dom/utils/options.es.js';
6
-
7
- function useAnimation(ref, initial, target, options, onStart, onComplete) {
8
- const prevTarget = useRef(initial);
9
- useEffect(() => {
10
- const targetKeyframe = {};
11
- const allKeys = new Set([
12
- ...Object.keys(target),
13
- ...Object.keys(prevTarget.current),
14
- ]);
15
- allKeys.forEach((key) => {
16
- let next = target[key];
17
- if (!hasChanged(next, prevTarget.current[key]))
18
- return;
19
- /**
20
- * TODO: If next is undefined, throw error or record a "base value"
21
- * to animate back down to
22
- */
23
- targetKeyframe[key] = next;
24
- });
25
- if (Object.keys(targetKeyframe).length && ref.current) {
26
- onStart === null || onStart === void 0 ? void 0 : onStart(targetKeyframe);
27
- const animationFactories = [];
28
- for (const key in targetKeyframe) {
29
- const animation = animateStyle(ref.current, key, targetKeyframe[key], getOptions(options, key));
30
- animationFactories.push(animation);
31
- }
32
- const animations = animationFactories
33
- .map((factory) => factory())
34
- .filter(Boolean);
35
- Promise.all(animations.map((animation) => animation.finished))
36
- .then(() => onComplete === null || onComplete === void 0 ? void 0 : onComplete(targetKeyframe))
37
- .catch(noop);
38
- }
39
- prevTarget.current = target;
40
- });
41
- }
42
-
43
- export { useAnimation };
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var framerMotion = require('framer-motion');
6
- var React = require('react');
7
- var poses = require('../utils/poses.cjs.js');
8
- var updateTarget = require('../utils/update-target.cjs.js');
9
-
10
- function useExit(target, options, { exit, poses: poses$1 }, { exit: inheritedExit }) {
11
- const [isPresent, onExitComplete] = framerMotion.usePresence();
12
- /**
13
- * In case we don't have an exit animation defined we still need to
14
- * call onExitComplete if it exits so AnimatePresence knows it
15
- * can remove this component.
16
- */
17
- React.useEffect(() => {
18
- if (!exit)
19
- onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
20
- }, [isPresent]);
21
- if (exit && !isPresent) {
22
- updateTarget.updateTargetAndOptions(target, options, poses.resolvePose(exit, inheritedExit, poses$1));
23
- return onExitComplete;
24
- }
25
- }
26
-
27
- exports.useExit = useExit;
@@ -1,23 +0,0 @@
1
- import { usePresence } from 'framer-motion';
2
- import { useEffect } from 'react';
3
- import { resolvePose } from '../utils/poses.es.js';
4
- import { updateTargetAndOptions } from '../utils/update-target.es.js';
5
-
6
- function useExit(target, options, { exit, poses }, { exit: inheritedExit }) {
7
- const [isPresent, onExitComplete] = usePresence();
8
- /**
9
- * In case we don't have an exit animation defined we still need to
10
- * call onExitComplete if it exits so AnimatePresence knows it
11
- * can remove this component.
12
- */
13
- useEffect(() => {
14
- if (!exit)
15
- onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete();
16
- }, [isPresent]);
17
- if (exit && !isPresent) {
18
- updateTargetAndOptions(target, options, resolvePose(exit, inheritedExit, poses));
19
- return onExitComplete;
20
- }
21
- }
22
-
23
- export { useExit };
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
- var poses = require('../utils/poses.cjs.js');
7
- var updateTarget = require('../utils/update-target.cjs.js');
8
-
9
- function useGestureState(target, options, stylesToApply, inheritedPose, poses$1) {
10
- const [isGestureActive, setGestureState] = React.useState(false);
11
- if (isGestureActive || inheritedPose) {
12
- updateTarget.updateTargetAndOptions(target, options, poses.resolvePose(stylesToApply, inheritedPose, poses$1));
13
- }
14
- return [isGestureActive || Boolean(inheritedPose), setGestureState];
15
- }
16
-
17
- exports.useGestureState = useGestureState;
@@ -1,13 +0,0 @@
1
- import { useState } from 'react';
2
- import { resolvePose } from '../utils/poses.es.js';
3
- import { updateTargetAndOptions } from '../utils/update-target.es.js';
4
-
5
- function useGestureState(target, options, stylesToApply, inheritedPose, poses) {
6
- const [isGestureActive, setGestureState] = useState(false);
7
- if (isGestureActive || inheritedPose) {
8
- updateTargetAndOptions(target, options, resolvePose(stylesToApply, inheritedPose, poses));
9
- }
10
- return [isGestureActive || Boolean(inheritedPose), setGestureState];
11
- }
12
-
13
- export { useGestureState };
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var useGestureState = require('./use-gesture-state.cjs.js');
6
-
7
- function useHover(target, options, { hover, onPointerEnter, onPointerLeave, poses, } = {}, { hover: inheritedHover }, isPoseActive) {
8
- const [isHoverActive, setHoverState] = useGestureState.useGestureState(target, options, hover, inheritedHover, poses);
9
- isPoseActive.hover = isHoverActive;
10
- return hover
11
- ? {
12
- onPointerEnter: (e) => {
13
- onPointerEnter === null || onPointerEnter === void 0 ? void 0 : onPointerEnter(e);
14
- setHoverState(true);
15
- },
16
- onPointerLeave: (e) => {
17
- onPointerLeave === null || onPointerLeave === void 0 ? void 0 : onPointerLeave(e);
18
- setHoverState(false);
19
- },
20
- }
21
- : {};
22
- }
23
-
24
- exports.useHover = useHover;
@@ -1,20 +0,0 @@
1
- import { useGestureState } from './use-gesture-state.es.js';
2
-
3
- function useHover(target, options, { hover, onPointerEnter, onPointerLeave, poses, } = {}, { hover: inheritedHover }, isPoseActive) {
4
- const [isHoverActive, setHoverState] = useGestureState(target, options, hover, inheritedHover, poses);
5
- isPoseActive.hover = isHoverActive;
6
- return hover
7
- ? {
8
- onPointerEnter: (e) => {
9
- onPointerEnter === null || onPointerEnter === void 0 ? void 0 : onPointerEnter(e);
10
- setHoverState(true);
11
- },
12
- onPointerLeave: (e) => {
13
- onPointerLeave === null || onPointerLeave === void 0 ? void 0 : onPointerLeave(e);
14
- setHoverState(false);
15
- },
16
- }
17
- : {};
18
- }
19
-
20
- export { useHover };
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var useGestureState = require('./use-gesture-state.cjs.js');
6
-
7
- function usePress(target, options, { press, onPointerDown, poses } = {}, { press: inheritedPress }, isPoseActive) {
8
- const [isPressActive, setPressState] = useGestureState.useGestureState(target, options, press, inheritedPress, poses);
9
- isPoseActive.press = isPressActive;
10
- if (!press)
11
- return {};
12
- const onPointerUp = () => {
13
- setPressState(false);
14
- window.removeEventListener("pointerup", onPointerUp);
15
- };
16
- return {
17
- onPointerDown: (e) => {
18
- onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(e);
19
- setPressState(true);
20
- window.addEventListener("pointerup", onPointerUp);
21
- },
22
- };
23
- }
24
-
25
- exports.usePress = usePress;
@@ -1,21 +0,0 @@
1
- import { useGestureState } from './use-gesture-state.es.js';
2
-
3
- function usePress(target, options, { press, onPointerDown, poses } = {}, { press: inheritedPress }, isPoseActive) {
4
- const [isPressActive, setPressState] = useGestureState(target, options, press, inheritedPress, poses);
5
- isPoseActive.press = isPressActive;
6
- if (!press)
7
- return {};
8
- const onPointerUp = () => {
9
- setPressState(false);
10
- window.removeEventListener("pointerup", onPointerUp);
11
- };
12
- return {
13
- onPointerDown: (e) => {
14
- onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(e);
15
- setPressState(true);
16
- window.addEventListener("pointerup", onPointerUp);
17
- },
18
- };
19
- }
20
-
21
- export { usePress };
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var React = require('react');
6
- var useGestureState = require('./use-gesture-state.cjs.js');
7
-
8
- function useViewport(ref, target, options, { inViewport, poses, viewport = {}, onViewportEnter, onViewportLeave, }, { inViewport: inheritedInViewport }, isPoseActive) {
9
- const { root, margin: rootMargin, once, threshold } = viewport;
10
- const [isInViewport, setViewportState] = useGestureState.useGestureState(target, options, inViewport, inheritedInViewport, poses);
11
- isPoseActive.inViewport = isInViewport;
12
- let shouldObserve = !!inViewport || !!onViewportEnter || !!onViewportLeave;
13
- if (once && isInViewport)
14
- shouldObserve = false;
15
- React.useEffect(() => {
16
- if (!shouldObserve || typeof IntersectionObserver === "undefined")
17
- return;
18
- const observer = new IntersectionObserver(([entry]) => {
19
- setViewportState(entry.isIntersecting);
20
- const callback = entry.isIntersecting
21
- ? onViewportEnter
22
- : onViewportLeave;
23
- callback && callback(entry);
24
- }, { root: root === null || root === void 0 ? void 0 : root.current, rootMargin, threshold });
25
- observer.observe(ref.current);
26
- return () => observer.disconnect();
27
- }, [
28
- inViewport,
29
- onViewportEnter,
30
- onViewportLeave,
31
- root,
32
- rootMargin,
33
- threshold,
34
- ]);
35
- }
36
-
37
- exports.useViewport = useViewport;
@@ -1,33 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { useGestureState } from './use-gesture-state.es.js';
3
-
4
- function useViewport(ref, target, options, { inViewport, poses, viewport = {}, onViewportEnter, onViewportLeave, }, { inViewport: inheritedInViewport }, isPoseActive) {
5
- const { root, margin: rootMargin, once, threshold } = viewport;
6
- const [isInViewport, setViewportState] = useGestureState(target, options, inViewport, inheritedInViewport, poses);
7
- isPoseActive.inViewport = isInViewport;
8
- let shouldObserve = !!inViewport || !!onViewportEnter || !!onViewportLeave;
9
- if (once && isInViewport)
10
- shouldObserve = false;
11
- useEffect(() => {
12
- if (!shouldObserve || typeof IntersectionObserver === "undefined")
13
- return;
14
- const observer = new IntersectionObserver(([entry]) => {
15
- setViewportState(entry.isIntersecting);
16
- const callback = entry.isIntersecting
17
- ? onViewportEnter
18
- : onViewportLeave;
19
- callback && callback(entry);
20
- }, { root: root === null || root === void 0 ? void 0 : root.current, rootMargin, threshold });
21
- observer.observe(ref.current);
22
- return () => observer.disconnect();
23
- }, [
24
- inViewport,
25
- onViewportEnter,
26
- onViewportLeave,
27
- root,
28
- rootMargin,
29
- threshold,
30
- ]);
31
- }
32
-
33
- export { useViewport };
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var animated$1 = require('./animated.cjs.js');
6
-
7
- const components = new Map();
8
- const animated = new Proxy({}, {
9
- get: (_, key) => {
10
- if (!components.has(key)) {
11
- components.set(key, animated$1.createAnimatedComponent(key));
12
- }
13
- return components.get(key);
14
- },
15
- });
16
-
17
- exports.animated = animated;
@@ -1,13 +0,0 @@
1
- import { createAnimatedComponent } from './animated.es.js';
2
-
3
- const components = new Map();
4
- const animated = new Proxy({}, {
5
- get: (_, key) => {
6
- if (!components.has(key)) {
7
- components.set(key, createAnimatedComponent(key));
8
- }
9
- return components.get(key);
10
- },
11
- });
12
-
13
- export { animated };
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function hasChanged(a, b) {
6
- if (typeof a !== typeof b)
7
- return true;
8
- if (Array.isArray(a) && Array.isArray(b))
9
- return !shallowCompare(a, b);
10
- return a !== b;
11
- }
12
- function shallowCompare(next, prev) {
13
- const prevLength = prev.length;
14
- if (prevLength !== next.length)
15
- return false;
16
- for (let i = 0; i < prevLength; i++) {
17
- if (prev[i] !== next[i])
18
- return false;
19
- }
20
- return true;
21
- }
22
-
23
- exports.hasChanged = hasChanged;
24
- exports.shallowCompare = shallowCompare;
@@ -1,19 +0,0 @@
1
- function hasChanged(a, b) {
2
- if (typeof a !== typeof b)
3
- return true;
4
- if (Array.isArray(a) && Array.isArray(b))
5
- return !shallowCompare(a, b);
6
- return a !== b;
7
- }
8
- function shallowCompare(next, prev) {
9
- const prevLength = prev.length;
10
- if (prevLength !== next.length)
11
- return false;
12
- for (let i = 0; i < prevLength; i++) {
13
- if (prev[i] !== next[i])
14
- return false;
15
- }
16
- return true;
17
- }
18
-
19
- export { hasChanged, shallowCompare };
@@ -1,38 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var isNumber = require('../../../utils/is-number.cjs.js');
6
- var transforms = require('../../dom/utils/transforms.cjs.js');
7
-
8
- function convertKeyframesToStyles(keyframes) {
9
- const initialKeyframes = {};
10
- const transformKeys = [];
11
- for (let key in keyframes) {
12
- const value = keyframes[key];
13
- if (transforms.isTransform(key)) {
14
- if (transforms.transformAlias[key])
15
- key = transforms.transformAlias[key];
16
- transformKeys.push(key);
17
- key = transforms.asTransformCssVar(key);
18
- }
19
- let initialKeyframe = Array.isArray(value) ? value[0] : value;
20
- /**
21
- * If this is a number and we have a default value type, convert the number
22
- * to this type.
23
- */
24
- const definition = transforms.transformDefinitions.get(key);
25
- if (definition) {
26
- initialKeyframe = isNumber.isNumber(value)
27
- ? definition.toDefaultUnit(value)
28
- : value;
29
- }
30
- initialKeyframes[key] = initialKeyframe;
31
- }
32
- if (transformKeys.length) {
33
- initialKeyframes.transform = transforms.buildTransformTemplate(transformKeys);
34
- }
35
- return initialKeyframes;
36
- }
37
-
38
- exports.convertKeyframesToStyles = convertKeyframesToStyles;
@@ -1,34 +0,0 @@
1
- import { isNumber } from '../../../utils/is-number.es.js';
2
- import { isTransform, transformAlias, asTransformCssVar, transformDefinitions, buildTransformTemplate } from '../../dom/utils/transforms.es.js';
3
-
4
- function convertKeyframesToStyles(keyframes) {
5
- const initialKeyframes = {};
6
- const transformKeys = [];
7
- for (let key in keyframes) {
8
- const value = keyframes[key];
9
- if (isTransform(key)) {
10
- if (transformAlias[key])
11
- key = transformAlias[key];
12
- transformKeys.push(key);
13
- key = asTransformCssVar(key);
14
- }
15
- let initialKeyframe = Array.isArray(value) ? value[0] : value;
16
- /**
17
- * If this is a number and we have a default value type, convert the number
18
- * to this type.
19
- */
20
- const definition = transformDefinitions.get(key);
21
- if (definition) {
22
- initialKeyframe = isNumber(value)
23
- ? definition.toDefaultUnit(value)
24
- : value;
25
- }
26
- initialKeyframes[key] = initialKeyframe;
27
- }
28
- if (transformKeys.length) {
29
- initialKeyframes.transform = buildTransformTemplate(transformKeys);
30
- }
31
- return initialKeyframes;
32
- }
33
-
34
- export { convertKeyframesToStyles };
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function resolvePose(definition, inheritedDefinition, poses = {}) {
6
- if (definition) {
7
- return typeof definition === "string" ? poses[definition] : definition;
8
- }
9
- else if (inheritedDefinition) {
10
- return poses[inheritedDefinition];
11
- }
12
- }
13
-
14
- exports.resolvePose = resolvePose;
@@ -1,10 +0,0 @@
1
- function resolvePose(definition, inheritedDefinition, poses = {}) {
2
- if (definition) {
3
- return typeof definition === "string" ? poses[definition] : definition;
4
- }
5
- else if (inheritedDefinition) {
6
- return poses[inheritedDefinition];
7
- }
8
- }
9
-
10
- export { resolvePose };
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var options = require('../../dom/utils/options.cjs.js');
6
-
7
- function updateTargetAndOptions(target, options$1, toApply) {
8
- if (!toApply)
9
- return;
10
- for (const key in toApply) {
11
- if (key === "options")
12
- continue;
13
- target[key] = toApply[key];
14
- if (toApply.options) {
15
- options$1[key] = options.getOptions(toApply.options, key);
16
- }
17
- }
18
- }
19
-
20
- exports.updateTargetAndOptions = updateTargetAndOptions;
@@ -1,16 +0,0 @@
1
- import { getOptions } from '../../dom/utils/options.es.js';
2
-
3
- function updateTargetAndOptions(target, options, toApply) {
4
- if (!toApply)
5
- return;
6
- for (const key in toApply) {
7
- if (key === "options")
8
- continue;
9
- target[key] = toApply[key];
10
- if (toApply.options) {
11
- options[key] = getOptions(toApply.options, key);
12
- }
13
- }
14
- }
15
-
16
- export { updateTargetAndOptions };
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function addUniqueItem(array, item) {
6
- array.indexOf(item) === -1 && array.push(item);
7
- }
8
- function removeItem(arr, item) {
9
- const index = arr.indexOf(item);
10
- index > -1 && arr.splice(index, 1);
11
- }
12
-
13
- exports.addUniqueItem = addUniqueItem;
14
- exports.removeItem = removeItem;
@@ -1,9 +0,0 @@
1
- function addUniqueItem(array, item) {
2
- array.indexOf(item) === -1 && array.push(item);
3
- }
4
- function removeItem(arr, item) {
5
- const index = arr.indexOf(item);
6
- index > -1 && arr.splice(index, 1);
7
- }
8
-
9
- export { addUniqueItem, removeItem };
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const clamp = (min, max, v) => Math.min(Math.max(v, min), max);
6
-
7
- exports.clamp = clamp;
@@ -1,3 +0,0 @@
1
- const clamp = (min, max, v) => Math.min(Math.max(v, min), max);
2
-
3
- export { clamp };
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const isNumber = (value) => typeof value === "number";
6
-
7
- exports.isNumber = isNumber;
@@ -1,3 +0,0 @@
1
- const isNumber = (value) => typeof value === "number";
2
-
3
- export { isNumber };
@@ -1,28 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- /*
6
- Value in range from progress
7
-
8
- Given a lower limit and an upper limit, we return the value within
9
- that range as expressed by progress (usually a number from 0 to 1)
10
-
11
- So progress = 0.5 would change
12
-
13
- from -------- to
14
-
15
- to
16
-
17
- from ---- to
18
-
19
- E.g. from = 10, to = 20, progress = 0.5 => 15
20
-
21
- @param [number]: Lower limit of range
22
- @param [number]: Upper limit of range
23
- @param [number]: The progress between lower and upper limits expressed 0-1
24
- @return [number]: Value as calculated from progress within range (not limited within range)
25
- */
26
- const mix = (from, to, progress) => -progress * from + progress * to + from;
27
-
28
- exports.mix = mix;