motion 10.4.0 → 10.5.0-alpha.1

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 (203) 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 +8 -1292
  6. package/dist/size-index.js +1 -0
  7. package/lib/index.js +5 -0
  8. package/lib/index.js.map +1 -0
  9. package/package.json +5 -138
  10. package/types/index.d.ts +3 -7
  11. package/types/index.d.ts.map +1 -0
  12. package/CHANGELOG.md +0 -103
  13. package/LICENSE +0 -21
  14. package/dist/react.cjs.js +0 -9
  15. package/dist/react.es.js +0 -1
  16. package/dist/size-animate-dom.js +0 -1
  17. package/dist/size-animate-style.js +0 -1
  18. package/dist/size-react.js +0 -1
  19. package/dist/size-spring.js +0 -1
  20. package/dist/size-timeline-dom.js +0 -1
  21. package/dist/size-webpack-animate.js +0 -1
  22. package/dist/targets/dom/animate-style.cjs.js +0 -182
  23. package/dist/targets/dom/animate-style.es.js +0 -178
  24. package/dist/targets/dom/animate.cjs.js +0 -42
  25. package/dist/targets/dom/animate.es.js +0 -38
  26. package/dist/targets/dom/data.cjs.js +0 -18
  27. package/dist/targets/dom/data.es.js +0 -14
  28. package/dist/targets/dom/style.cjs.js +0 -22
  29. package/dist/targets/dom/style.es.js +0 -18
  30. package/dist/targets/dom/timeline/index.cjs.js +0 -190
  31. package/dist/targets/dom/timeline/index.es.js +0 -185
  32. package/dist/targets/dom/timeline/utils/calc-time.cjs.js +0 -23
  33. package/dist/targets/dom/timeline/utils/calc-time.es.js +0 -19
  34. package/dist/targets/dom/timeline/utils/edit.cjs.js +0 -36
  35. package/dist/targets/dom/timeline/utils/edit.es.js +0 -31
  36. package/dist/targets/dom/timeline/utils/sort.cjs.js +0 -14
  37. package/dist/targets/dom/timeline/utils/sort.es.js +0 -10
  38. package/dist/targets/dom/utils/apply.cjs.js +0 -9
  39. package/dist/targets/dom/utils/apply.es.js +0 -4
  40. package/dist/targets/dom/utils/controls.cjs.js +0 -59
  41. package/dist/targets/dom/utils/controls.es.js +0 -54
  42. package/dist/targets/dom/utils/css-var.cjs.js +0 -29
  43. package/dist/targets/dom/utils/css-var.es.js +0 -23
  44. package/dist/targets/dom/utils/defaults.cjs.js +0 -13
  45. package/dist/targets/dom/utils/defaults.es.js +0 -9
  46. package/dist/targets/dom/utils/easing.cjs.js +0 -18
  47. package/dist/targets/dom/utils/easing.es.js +0 -10
  48. package/dist/targets/dom/utils/feature-detection.cjs.js +0 -31
  49. package/dist/targets/dom/utils/feature-detection.es.js +0 -27
  50. package/dist/targets/dom/utils/get-style-name.cjs.js +0 -13
  51. package/dist/targets/dom/utils/get-style-name.es.js +0 -9
  52. package/dist/targets/dom/utils/keyframes.cjs.js +0 -16
  53. package/dist/targets/dom/utils/keyframes.es.js +0 -11
  54. package/dist/targets/dom/utils/options.cjs.js +0 -13
  55. package/dist/targets/dom/utils/options.es.js +0 -9
  56. package/dist/targets/dom/utils/resolve-elements.cjs.js +0 -22
  57. package/dist/targets/dom/utils/resolve-elements.es.js +0 -18
  58. package/dist/targets/dom/utils/stop-animation.cjs.js +0 -19
  59. package/dist/targets/dom/utils/stop-animation.es.js +0 -15
  60. package/dist/targets/dom/utils/time.cjs.js +0 -7
  61. package/dist/targets/dom/utils/time.es.js +0 -3
  62. package/dist/targets/dom/utils/transforms.cjs.js +0 -85
  63. package/dist/targets/dom/utils/transforms.es.js +0 -74
  64. package/dist/targets/js/NumberAnimation.cjs.js +0 -144
  65. package/dist/targets/js/NumberAnimation.es.js +0 -140
  66. package/dist/targets/js/easing/cubic-bezier.cjs.js +0 -57
  67. package/dist/targets/js/easing/cubic-bezier.es.js +0 -53
  68. package/dist/targets/js/easing/glide/generator.cjs.js +0 -99
  69. package/dist/targets/js/easing/glide/generator.es.js +0 -95
  70. package/dist/targets/js/easing/glide/index.cjs.js +0 -10
  71. package/dist/targets/js/easing/glide/index.es.js +0 -6
  72. package/dist/targets/js/easing/spring/generator.cjs.js +0 -64
  73. package/dist/targets/js/easing/spring/generator.es.js +0 -57
  74. package/dist/targets/js/easing/spring/index.cjs.js +0 -10
  75. package/dist/targets/js/easing/spring/index.es.js +0 -6
  76. package/dist/targets/js/easing/steps.cjs.js +0 -15
  77. package/dist/targets/js/easing/steps.es.js +0 -11
  78. package/dist/targets/js/easing/utils/create-generator-easing.cjs.js +0 -71
  79. package/dist/targets/js/easing/utils/create-generator-easing.es.js +0 -67
  80. package/dist/targets/js/easing/utils/get-function.cjs.js +0 -37
  81. package/dist/targets/js/easing/utils/get-function.es.js +0 -33
  82. package/dist/targets/js/easing/utils/has-reached-target.cjs.js +0 -10
  83. package/dist/targets/js/easing/utils/has-reached-target.es.js +0 -6
  84. package/dist/targets/js/easing/utils/pregenerate-keyframes.cjs.js +0 -34
  85. package/dist/targets/js/easing/utils/pregenerate-keyframes.es.js +0 -30
  86. package/dist/targets/js/utils/get-easing.cjs.js +0 -14
  87. package/dist/targets/js/utils/get-easing.es.js +0 -10
  88. package/dist/targets/js/utils/interpolate.cjs.js +0 -35
  89. package/dist/targets/js/utils/interpolate.es.js +0 -31
  90. package/dist/targets/js/utils/offset.cjs.js +0 -22
  91. package/dist/targets/js/utils/offset.es.js +0 -17
  92. package/dist/targets/react/animated.cjs.js +0 -126
  93. package/dist/targets/react/animated.es.js +0 -101
  94. package/dist/targets/react/context.cjs.js +0 -9
  95. package/dist/targets/react/context.es.js +0 -5
  96. package/dist/targets/react/hooks/use-animation.cjs.js +0 -47
  97. package/dist/targets/react/hooks/use-animation.es.js +0 -43
  98. package/dist/targets/react/hooks/use-exit.cjs.js +0 -27
  99. package/dist/targets/react/hooks/use-exit.es.js +0 -23
  100. package/dist/targets/react/hooks/use-gesture-state.cjs.js +0 -17
  101. package/dist/targets/react/hooks/use-gesture-state.es.js +0 -13
  102. package/dist/targets/react/hooks/use-hover.cjs.js +0 -24
  103. package/dist/targets/react/hooks/use-hover.es.js +0 -20
  104. package/dist/targets/react/hooks/use-press.cjs.js +0 -25
  105. package/dist/targets/react/hooks/use-press.es.js +0 -21
  106. package/dist/targets/react/hooks/use-viewport.cjs.js +0 -37
  107. package/dist/targets/react/hooks/use-viewport.es.js +0 -33
  108. package/dist/targets/react/index.cjs.js +0 -17
  109. package/dist/targets/react/index.es.js +0 -13
  110. package/dist/targets/react/utils/has-changed.cjs.js +0 -24
  111. package/dist/targets/react/utils/has-changed.es.js +0 -19
  112. package/dist/targets/react/utils/keyframes.cjs.js +0 -38
  113. package/dist/targets/react/utils/keyframes.es.js +0 -34
  114. package/dist/targets/react/utils/poses.cjs.js +0 -14
  115. package/dist/targets/react/utils/poses.es.js +0 -10
  116. package/dist/targets/react/utils/update-target.cjs.js +0 -20
  117. package/dist/targets/react/utils/update-target.es.js +0 -16
  118. package/dist/utils/array.cjs.js +0 -14
  119. package/dist/utils/array.es.js +0 -9
  120. package/dist/utils/clamp.cjs.js +0 -7
  121. package/dist/utils/clamp.es.js +0 -3
  122. package/dist/utils/is-number.cjs.js +0 -7
  123. package/dist/utils/is-number.es.js +0 -3
  124. package/dist/utils/mix.cjs.js +0 -28
  125. package/dist/utils/mix.es.js +0 -24
  126. package/dist/utils/noop.cjs.js +0 -9
  127. package/dist/utils/noop.es.js +0 -4
  128. package/dist/utils/progress.cjs.js +0 -20
  129. package/dist/utils/progress.es.js +0 -16
  130. package/dist/utils/stagger.cjs.js +0 -38
  131. package/dist/utils/stagger.es.js +0 -32
  132. package/dist/utils/velocity-per-second.cjs.js +0 -15
  133. package/dist/utils/velocity-per-second.es.js +0 -11
  134. package/dist/utils/wrap.cjs.js +0 -10
  135. package/dist/utils/wrap.es.js +0 -6
  136. package/react/package.json +0 -6
  137. package/types/react-entry.d.ts +0 -2
  138. package/types/targets/dom/animate-style.d.ts +0 -2
  139. package/types/targets/dom/animate.d.ts +0 -2
  140. package/types/targets/dom/data.d.ts +0 -2
  141. package/types/targets/dom/style.d.ts +0 -3
  142. package/types/targets/dom/timeline/index.d.ts +0 -15
  143. package/types/targets/dom/timeline/types.d.ts +0 -13
  144. package/types/targets/dom/timeline/utils/calc-time.d.ts +0 -2
  145. package/types/targets/dom/timeline/utils/edit.d.ts +0 -4
  146. package/types/targets/dom/timeline/utils/sort.d.ts +0 -2
  147. package/types/targets/dom/types.d.ts +0 -114
  148. package/types/targets/dom/utils/apply.d.ts +0 -3
  149. package/types/targets/dom/utils/controls.d.ts +0 -12
  150. package/types/targets/dom/utils/css-var.d.ts +0 -3
  151. package/types/targets/dom/utils/defaults.d.ts +0 -8
  152. package/types/targets/dom/utils/easing.d.ts +0 -6
  153. package/types/targets/dom/utils/feature-detection.d.ts +0 -8
  154. package/types/targets/dom/utils/get-style-name.d.ts +0 -1
  155. package/types/targets/dom/utils/keyframes.d.ts +0 -3
  156. package/types/targets/dom/utils/options.d.ts +0 -2
  157. package/types/targets/dom/utils/resolve-elements.d.ts +0 -4
  158. package/types/targets/dom/utils/stop-animation.d.ts +0 -6
  159. package/types/targets/dom/utils/time.d.ts +0 -1
  160. package/types/targets/dom/utils/transforms.d.ts +0 -20
  161. package/types/targets/js/NumberAnimation.d.ts +0 -24
  162. package/types/targets/js/easing/cubic-bezier.d.ts +0 -1
  163. package/types/targets/js/easing/glide/generator.d.ts +0 -5
  164. package/types/targets/js/easing/glide/index.d.ts +0 -2
  165. package/types/targets/js/easing/glide/types.d.ts +0 -14
  166. package/types/targets/js/easing/spring/generator.d.ts +0 -6
  167. package/types/targets/js/easing/spring/index.d.ts +0 -2
  168. package/types/targets/js/easing/spring/types.d.ts +0 -10
  169. package/types/targets/js/easing/steps.d.ts +0 -3
  170. package/types/targets/js/easing/utils/create-generator-easing.d.ts +0 -3
  171. package/types/targets/js/easing/utils/get-function.d.ts +0 -3
  172. package/types/targets/js/easing/utils/has-reached-target.d.ts +0 -1
  173. package/types/targets/js/easing/utils/pregenerate-keyframes.d.ts +0 -7
  174. package/types/targets/js/types.d.ts +0 -12
  175. package/types/targets/js/utils/get-easing.d.ts +0 -1
  176. package/types/targets/js/utils/interpolate.d.ts +0 -2
  177. package/types/targets/js/utils/offset.d.ts +0 -2
  178. package/types/targets/react/animated.d.ts +0 -3
  179. package/types/targets/react/context.d.ts +0 -3
  180. package/types/targets/react/hooks/use-animation.d.ts +0 -4
  181. package/types/targets/react/hooks/use-exit.d.ts +0 -3
  182. package/types/targets/react/hooks/use-gesture-state.d.ts +0 -4
  183. package/types/targets/react/hooks/use-hover.d.ts +0 -4
  184. package/types/targets/react/hooks/use-press.d.ts +0 -4
  185. package/types/targets/react/hooks/use-viewport.d.ts +0 -4
  186. package/types/targets/react/index.d.ts +0 -2
  187. package/types/targets/react/types.d.ts +0 -108
  188. package/types/targets/react/utils/has-changed.d.ts +0 -2
  189. package/types/targets/react/utils/keyframes.d.ts +0 -3
  190. package/types/targets/react/utils/poses.d.ts +0 -2
  191. package/types/targets/react/utils/supported-elements.d.ts +0 -8
  192. package/types/targets/react/utils/update-target.d.ts +0 -3
  193. package/types/utils/array.d.ts +0 -2
  194. package/types/utils/clamp.d.ts +0 -1
  195. package/types/utils/interpolate.d.ts +0 -0
  196. package/types/utils/is-number.d.ts +0 -1
  197. package/types/utils/mix.d.ts +0 -1
  198. package/types/utils/noop.d.ts +0 -2
  199. package/types/utils/progress.d.ts +0 -1
  200. package/types/utils/stagger.d.ts +0 -12
  201. package/types/utils/value-types.d.ts +0 -0
  202. package/types/utils/velocity-per-second.d.ts +0 -1
  203. package/types/utils/wrap.d.ts +0 -1
@@ -1,185 +0,0 @@
1
- import { __rest } from 'tslib';
2
- import { invariant } from 'hey-listen';
3
- import { progress } from '../../../utils/progress.es.js';
4
- import { resolveOption } from '../../../utils/stagger.es.js';
5
- import { defaultOffset, fillOffset } from '../../js/utils/offset.es.js';
6
- import { animateStyle } from '../animate-style.es.js';
7
- import { createAnimations } from '../utils/controls.es.js';
8
- import { defaults } from '../utils/defaults.es.js';
9
- import { isCustomEasing } from '../utils/easing.es.js';
10
- import { keyframesList } from '../utils/keyframes.es.js';
11
- import { getOptions } from '../utils/options.es.js';
12
- import { resolveElements } from '../utils/resolve-elements.es.js';
13
- import { isTransform } from '../utils/transforms.es.js';
14
- import { calcNextTime } from './utils/calc-time.es.js';
15
- import { addKeyframes } from './utils/edit.es.js';
16
- import { compareByTime } from './utils/sort.es.js';
17
-
18
- function timeline(definition, options = {}) {
19
- var _a, _b;
20
- const animationDefinitions = createAnimationsFromTimeline(definition, options);
21
- /**
22
- * Create and start animations
23
- */
24
- const animationFactories = animationDefinitions
25
- .map((definition) => animateStyle(...definition))
26
- .filter(Boolean);
27
- return createAnimations(animationFactories,
28
- // Get the duration from the first animation definition
29
- (_b = (_a = animationDefinitions[0]) === null || _a === void 0 ? void 0 : _a[3].duration) !== null && _b !== void 0 ? _b : defaults.duration);
30
- }
31
- function createAnimationsFromTimeline(definition, _a = {}) {
32
- var { defaultOptions = {} } = _a, timelineOptions = __rest(_a, ["defaultOptions"]);
33
- const animationDefinitions = [];
34
- const elementSequences = new Map();
35
- const elementCache = {};
36
- const timeLabels = new Map();
37
- let prevTime = 0;
38
- let currentTime = 0;
39
- let totalDuration = 0;
40
- /**
41
- * Build the timeline by mapping over the definition array and converting
42
- * the definitions into keyframes and offsets with absolute time values.
43
- * These will later get converted into relative offsets in a second pass.
44
- */
45
- for (let i = 0; i < definition.length; i++) {
46
- const [elementDefinition, keyframes, options = {}] = definition[i];
47
- /**
48
- * If a relative or absolute time value has been specified we need to resolve
49
- * it in relation to the currentTime.
50
- */
51
- if (options.at !== undefined) {
52
- currentTime = calcNextTime(currentTime, options.at, prevTime, timeLabels);
53
- }
54
- /**
55
- * Keep track of the maximum duration in this definition. This will be
56
- * applied to currentTime once the definition has been parsed.
57
- */
58
- let maxDuration = 0;
59
- /**
60
- * Find all the elements specified in the definition and parse value
61
- * keyframes from their timeline definitions.
62
- */
63
- const elements = resolveElements(elementDefinition, elementCache);
64
- const numElements = elements.length;
65
- for (let elementIndex = 0; elementIndex < numElements; elementIndex++) {
66
- const element = elements[elementIndex];
67
- const elementSequence = getElementSequence(element, elementSequences);
68
- for (const key in keyframes) {
69
- const valueSequence = getValueSequence(key, elementSequence);
70
- let valueKeyframes = keyframesList(keyframes[key]);
71
- const valueOptions = getOptions(options, key);
72
- let { duration = defaultOptions.duration || defaults.duration, easing = defaultOptions.easing || defaults.easing, } = valueOptions;
73
- if (isCustomEasing(easing)) {
74
- const valueIsTransform = isTransform(key);
75
- invariant(valueKeyframes.length === 2 || !valueIsTransform, "spring must be provided 2 keyframes within timeline");
76
- const custom = easing.createAnimation(valueKeyframes,
77
- // TODO We currently only support explicit keyframes
78
- // so this doesn't currently read from the DOM
79
- () => "0", valueIsTransform);
80
- easing = custom.easing;
81
- if (custom.keyframes !== undefined)
82
- valueKeyframes = custom.keyframes;
83
- if (custom.duration !== undefined)
84
- duration = custom.duration;
85
- }
86
- const delay = resolveOption(options.delay, elementIndex, numElements) || 0;
87
- const startTime = currentTime + delay;
88
- const targetTime = startTime + duration;
89
- /**
90
- *
91
- */
92
- let { offset = defaultOffset(valueKeyframes.length) } = valueOptions;
93
- /**
94
- * If there's only one offset of 0, fill in a second with length 1
95
- *
96
- * TODO: Ensure there's a test that covers this removal
97
- */
98
- if (offset.length === 1 && offset[0] === 0) {
99
- offset[1] = 1;
100
- }
101
- /**
102
- * Fill out if offset if fewer offsets than keyframes
103
- */
104
- const remainder = length - valueKeyframes.length;
105
- remainder > 0 && fillOffset(offset, remainder);
106
- /**
107
- * If only one value has been set, ie [1], push a null to the start of
108
- * the keyframe array. This will let us mark a keyframe at this point
109
- * that will later be hydrated with the previous value.
110
- */
111
- valueKeyframes.length === 1 && valueKeyframes.unshift(null);
112
- /**
113
- * Add keyframes, mapping offsets to absolute time.
114
- */
115
- addKeyframes(valueSequence, valueKeyframes, easing, offset, startTime, targetTime);
116
- maxDuration = Math.max(delay + duration, maxDuration);
117
- totalDuration = Math.max(targetTime, totalDuration);
118
- }
119
- }
120
- prevTime = currentTime;
121
- currentTime += maxDuration;
122
- }
123
- /**
124
- * For every element and value combination create a new animation.
125
- */
126
- elementSequences.forEach((valueSequences, element) => {
127
- for (const key in valueSequences) {
128
- const valueSequence = valueSequences[key];
129
- /**
130
- * Arrange all the keyframes in ascending time order.
131
- */
132
- valueSequence.sort(compareByTime);
133
- const keyframes = [];
134
- const valueOffset = [];
135
- const valueEasing = [];
136
- /**
137
- * For each keyframe, translate absolute times into
138
- * relative offsets based on the total duration of the timeline.
139
- */
140
- for (let i = 0; i < valueSequence.length; i++) {
141
- const { at, value, easing } = valueSequence[i];
142
- keyframes.push(value);
143
- valueOffset.push(progress(0, totalDuration, at));
144
- valueEasing.push(easing || defaults.easing);
145
- }
146
- /**
147
- * If the first keyframe doesn't land on offset: 0
148
- * provide one by duplicating the initial keyframe. This ensures
149
- * it snaps to the first keyframe when the animation starts.
150
- */
151
- if (valueOffset[0] !== 0) {
152
- valueOffset.unshift(0);
153
- keyframes.unshift(keyframes[0]);
154
- valueEasing.unshift("linear");
155
- }
156
- /**
157
- * If the last keyframe doesn't land on offset: 1
158
- * provide one with a null wildcard value. This will ensure it
159
- * stays static until the end of the animation.
160
- */
161
- if (valueOffset[valueOffset.length - 1] !== 1) {
162
- valueOffset.push(1);
163
- keyframes.push(null);
164
- }
165
- animationDefinitions.push([
166
- element,
167
- key,
168
- keyframes,
169
- Object.assign(Object.assign(Object.assign({}, defaultOptions), { duration: totalDuration, easing: valueEasing, offset: valueOffset }), timelineOptions),
170
- ]);
171
- }
172
- });
173
- return animationDefinitions;
174
- }
175
- function getElementSequence(element, sequences) {
176
- !sequences.has(element) && sequences.set(element, {});
177
- return sequences.get(element);
178
- }
179
- function getValueSequence(name, sequences) {
180
- if (!sequences[name])
181
- sequences[name] = [];
182
- return sequences[name];
183
- }
184
-
185
- export { createAnimationsFromTimeline, timeline };
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var isNumber = require('../../../../utils/is-number.cjs.js');
6
-
7
- function calcNextTime(current, next, prev, labels) {
8
- var _a;
9
- if (isNumber.isNumber(next)) {
10
- return next;
11
- }
12
- else if (next.startsWith("-") || next.startsWith("+")) {
13
- return Math.max(0, current + parseFloat(next));
14
- }
15
- else if (next === "<") {
16
- return prev;
17
- }
18
- else {
19
- return (_a = labels.get(next)) !== null && _a !== void 0 ? _a : current;
20
- }
21
- }
22
-
23
- exports.calcNextTime = calcNextTime;
@@ -1,19 +0,0 @@
1
- import { isNumber } from '../../../../utils/is-number.es.js';
2
-
3
- function calcNextTime(current, next, prev, labels) {
4
- var _a;
5
- if (isNumber(next)) {
6
- return next;
7
- }
8
- else if (next.startsWith("-") || next.startsWith("+")) {
9
- return Math.max(0, current + parseFloat(next));
10
- }
11
- else if (next === "<") {
12
- return prev;
13
- }
14
- else {
15
- return (_a = labels.get(next)) !== null && _a !== void 0 ? _a : current;
16
- }
17
- }
18
-
19
- export { calcNextTime };
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var mix = require('../../../../utils/mix.cjs.js');
6
- var array = require('../../../../utils/array.cjs.js');
7
- var getEasing = require('../../../js/utils/get-easing.cjs.js');
8
-
9
- function eraseKeyframes(sequence, startTime, endTime) {
10
- for (let i = 0; i < sequence.length; i++) {
11
- const keyframe = sequence[i];
12
- if (keyframe.at > startTime && keyframe.at < endTime) {
13
- array.removeItem(sequence, keyframe);
14
- // If we remove this item we have to push the pointer back one
15
- i--;
16
- }
17
- }
18
- }
19
- function addKeyframes(sequence, keyframes, easing, offset, startTime, endTime) {
20
- /**
21
- * Erase every existing value between currentTime and targetTime,
22
- * this will essentially splice this timeline into any currently
23
- * defined ones.
24
- */
25
- eraseKeyframes(sequence, startTime, endTime);
26
- for (let i = 0; i < keyframes.length; i++) {
27
- sequence.push({
28
- value: keyframes[i],
29
- at: mix.mix(startTime, endTime, offset[i]),
30
- easing: getEasing.getEasingForSegment(easing, i),
31
- });
32
- }
33
- }
34
-
35
- exports.addKeyframes = addKeyframes;
36
- exports.eraseKeyframes = eraseKeyframes;
@@ -1,31 +0,0 @@
1
- import { mix } from '../../../../utils/mix.es.js';
2
- import { removeItem } from '../../../../utils/array.es.js';
3
- import { getEasingForSegment } from '../../../js/utils/get-easing.es.js';
4
-
5
- function eraseKeyframes(sequence, startTime, endTime) {
6
- for (let i = 0; i < sequence.length; i++) {
7
- const keyframe = sequence[i];
8
- if (keyframe.at > startTime && keyframe.at < endTime) {
9
- removeItem(sequence, keyframe);
10
- // If we remove this item we have to push the pointer back one
11
- i--;
12
- }
13
- }
14
- }
15
- function addKeyframes(sequence, keyframes, easing, offset, startTime, endTime) {
16
- /**
17
- * Erase every existing value between currentTime and targetTime,
18
- * this will essentially splice this timeline into any currently
19
- * defined ones.
20
- */
21
- eraseKeyframes(sequence, startTime, endTime);
22
- for (let i = 0; i < keyframes.length; i++) {
23
- sequence.push({
24
- value: keyframes[i],
25
- at: mix(startTime, endTime, offset[i]),
26
- easing: getEasingForSegment(easing, i),
27
- });
28
- }
29
- }
30
-
31
- export { addKeyframes, eraseKeyframes };
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function compareByTime(a, b) {
6
- if (a.at === b.at) {
7
- return a.value === null ? 1 : -1;
8
- }
9
- else {
10
- return a.at - b.at;
11
- }
12
- }
13
-
14
- exports.compareByTime = compareByTime;
@@ -1,10 +0,0 @@
1
- function compareByTime(a, b) {
2
- if (a.at === b.at) {
3
- return a.value === null ? 1 : -1;
4
- }
5
- else {
6
- return a.at - b.at;
7
- }
8
- }
9
-
10
- export { compareByTime };
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const cssVariableRenderer = (element, name) => (latest) => element.style.setProperty(name, latest);
6
- const styleRenderer = (element, name) => (latest) => (element.style[name] = latest);
7
-
8
- exports.cssVariableRenderer = cssVariableRenderer;
9
- exports.styleRenderer = styleRenderer;
@@ -1,4 +0,0 @@
1
- const cssVariableRenderer = (element, name) => (latest) => element.style.setProperty(name, latest);
2
- const styleRenderer = (element, name) => (latest) => (element.style[name] = latest);
3
-
4
- export { cssVariableRenderer, styleRenderer };
@@ -1,59 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var noop = require('../../../utils/noop.cjs.js');
6
- var stopAnimation = require('./stop-animation.cjs.js');
7
- var time = require('./time.cjs.js');
8
-
9
- const createAnimation = (factory) => factory();
10
- const createAnimations = (animationFactory, duration) => new Proxy({
11
- animations: animationFactory.map(createAnimation).filter(Boolean),
12
- duration,
13
- }, controls);
14
- /**
15
- * TODO:
16
- * Currently this returns the first animation, ideally it would return
17
- * the first active animation.
18
- */
19
- const getActiveAnimation = (state) => state.animations[0];
20
- const controls = {
21
- get: (target, key) => {
22
- var _a, _b;
23
- switch (key) {
24
- case "duration":
25
- return target.duration;
26
- case "currentTime":
27
- let time = ((_a = getActiveAnimation(target)) === null || _a === void 0 ? void 0 : _a[key]) || 0;
28
- return time ? time / 1000 : 0;
29
- case "playbackRate":
30
- return (_b = getActiveAnimation(target)) === null || _b === void 0 ? void 0 : _b[key];
31
- case "finished":
32
- if (!target.finished) {
33
- target.finished = Promise.all(target.animations.map(selectFinished)).catch(noop.noop);
34
- }
35
- return target.finished;
36
- case "stop":
37
- return () => target.animations.forEach(stopAnimation.stopAnimation);
38
- default:
39
- return () => target.animations.forEach((animation) => animation[key]());
40
- }
41
- },
42
- set: (target, key, value) => {
43
- switch (key) {
44
- case "currentTime":
45
- value = time.ms(value);
46
- case "currentTime":
47
- case "playbackRate":
48
- for (let i = 0; i < target.animations.length; i++) {
49
- target.animations[i][key] = value;
50
- }
51
- return true;
52
- }
53
- return false;
54
- },
55
- };
56
- const selectFinished = (animation) => animation.finished;
57
-
58
- exports.controls = controls;
59
- exports.createAnimations = createAnimations;
@@ -1,54 +0,0 @@
1
- import { noop } from '../../../utils/noop.es.js';
2
- import { stopAnimation } from './stop-animation.es.js';
3
- import { ms } from './time.es.js';
4
-
5
- const createAnimation = (factory) => factory();
6
- const createAnimations = (animationFactory, duration) => new Proxy({
7
- animations: animationFactory.map(createAnimation).filter(Boolean),
8
- duration,
9
- }, controls);
10
- /**
11
- * TODO:
12
- * Currently this returns the first animation, ideally it would return
13
- * the first active animation.
14
- */
15
- const getActiveAnimation = (state) => state.animations[0];
16
- const controls = {
17
- get: (target, key) => {
18
- var _a, _b;
19
- switch (key) {
20
- case "duration":
21
- return target.duration;
22
- case "currentTime":
23
- let time = ((_a = getActiveAnimation(target)) === null || _a === void 0 ? void 0 : _a[key]) || 0;
24
- return time ? time / 1000 : 0;
25
- case "playbackRate":
26
- return (_b = getActiveAnimation(target)) === null || _b === void 0 ? void 0 : _b[key];
27
- case "finished":
28
- if (!target.finished) {
29
- target.finished = Promise.all(target.animations.map(selectFinished)).catch(noop);
30
- }
31
- return target.finished;
32
- case "stop":
33
- return () => target.animations.forEach(stopAnimation);
34
- default:
35
- return () => target.animations.forEach((animation) => animation[key]());
36
- }
37
- },
38
- set: (target, key, value) => {
39
- switch (key) {
40
- case "currentTime":
41
- value = ms(value);
42
- case "currentTime":
43
- case "playbackRate":
44
- for (let i = 0; i < target.animations.length; i++) {
45
- target.animations[i][key] = value;
46
- }
47
- return true;
48
- }
49
- return false;
50
- },
51
- };
52
- const selectFinished = (animation) => animation.finished;
53
-
54
- export { controls, createAnimations };
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var transforms = require('./transforms.cjs.js');
6
-
7
- const isCssVar = (name) => name.startsWith("--");
8
- const registeredProperties = new Set();
9
- function registerCssVariable(name) {
10
- if (registeredProperties.has(name))
11
- return;
12
- registeredProperties.add(name);
13
- try {
14
- const { syntax, initialValue } = transforms.transformDefinitions.has(name)
15
- ? transforms.transformDefinitions.get(name)
16
- : {};
17
- CSS.registerProperty({
18
- name,
19
- inherits: false,
20
- syntax,
21
- initialValue,
22
- });
23
- }
24
- catch (e) { }
25
- }
26
-
27
- exports.isCssVar = isCssVar;
28
- exports.registerCssVariable = registerCssVariable;
29
- exports.registeredProperties = registeredProperties;
@@ -1,23 +0,0 @@
1
- import { transformDefinitions } from './transforms.es.js';
2
-
3
- const isCssVar = (name) => name.startsWith("--");
4
- const registeredProperties = new Set();
5
- function registerCssVariable(name) {
6
- if (registeredProperties.has(name))
7
- return;
8
- registeredProperties.add(name);
9
- try {
10
- const { syntax, initialValue } = transformDefinitions.has(name)
11
- ? transformDefinitions.get(name)
12
- : {};
13
- CSS.registerProperty({
14
- name,
15
- inherits: false,
16
- syntax,
17
- initialValue,
18
- });
19
- }
20
- catch (e) { }
21
- }
22
-
23
- export { isCssVar, registerCssVariable, registeredProperties };
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const defaults = {
6
- duration: 0.3,
7
- delay: 0,
8
- endDelay: 0,
9
- repeat: 0,
10
- easing: "ease",
11
- };
12
-
13
- exports.defaults = defaults;
@@ -1,9 +0,0 @@
1
- const defaults = {
2
- duration: 0.3,
3
- delay: 0,
4
- endDelay: 0,
5
- repeat: 0,
6
- easing: "ease",
7
- };
8
-
9
- export { defaults };
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var isNumber = require('../../../utils/is-number.cjs.js');
6
-
7
- const isCubicBezier = (easing) => Array.isArray(easing) && isNumber.isNumber(easing[0]);
8
- const isEasingList = (easing) => Array.isArray(easing) && !isNumber.isNumber(easing[0]);
9
- const isCustomEasing = (easing) => typeof easing === "object" &&
10
- Boolean(easing.createAnimation);
11
- const convertEasing = (easing) => isCubicBezier(easing) ? cubicBezierAsString(easing) : easing;
12
- const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
13
-
14
- exports.convertEasing = convertEasing;
15
- exports.cubicBezierAsString = cubicBezierAsString;
16
- exports.isCubicBezier = isCubicBezier;
17
- exports.isCustomEasing = isCustomEasing;
18
- exports.isEasingList = isEasingList;
@@ -1,10 +0,0 @@
1
- import { isNumber } from '../../../utils/is-number.es.js';
2
-
3
- const isCubicBezier = (easing) => Array.isArray(easing) && isNumber(easing[0]);
4
- const isEasingList = (easing) => Array.isArray(easing) && !isNumber(easing[0]);
5
- const isCustomEasing = (easing) => typeof easing === "object" &&
6
- Boolean(easing.createAnimation);
7
- const convertEasing = (easing) => isCubicBezier(easing) ? cubicBezierAsString(easing) : easing;
8
- const cubicBezierAsString = ([a, b, c, d]) => `cubic-bezier(${a}, ${b}, ${c}, ${d})`;
9
-
10
- export { convertEasing, cubicBezierAsString, isCubicBezier, isCustomEasing, isEasingList };
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const testAnimation = (keyframes) => document.createElement("div").animate(keyframes, { duration: 0.001 });
6
- const featureTests = {
7
- cssRegisterProperty: () => typeof CSS !== "undefined" &&
8
- Object.hasOwnProperty.call(CSS, "registerProperty"),
9
- waapi: () => Object.hasOwnProperty.call(Element.prototype, "animate"),
10
- partialKeyframes: () => {
11
- try {
12
- testAnimation({ opacity: [1] });
13
- }
14
- catch (e) {
15
- return false;
16
- }
17
- return true;
18
- },
19
- finished: () => Boolean(testAnimation({ opacity: [0, 1] }).finished),
20
- };
21
- const results = {};
22
- const supports = {};
23
- for (const key in featureTests) {
24
- supports[key] = () => {
25
- if (results[key] === undefined)
26
- results[key] = featureTests[key]();
27
- return results[key];
28
- };
29
- }
30
-
31
- exports.supports = supports;
@@ -1,27 +0,0 @@
1
- const testAnimation = (keyframes) => document.createElement("div").animate(keyframes, { duration: 0.001 });
2
- const featureTests = {
3
- cssRegisterProperty: () => typeof CSS !== "undefined" &&
4
- Object.hasOwnProperty.call(CSS, "registerProperty"),
5
- waapi: () => Object.hasOwnProperty.call(Element.prototype, "animate"),
6
- partialKeyframes: () => {
7
- try {
8
- testAnimation({ opacity: [1] });
9
- }
10
- catch (e) {
11
- return false;
12
- }
13
- return true;
14
- },
15
- finished: () => Boolean(testAnimation({ opacity: [0, 1] }).finished),
16
- };
17
- const results = {};
18
- const supports = {};
19
- for (const key in featureTests) {
20
- supports[key] = () => {
21
- if (results[key] === undefined)
22
- results[key] = featureTests[key]();
23
- return results[key];
24
- };
25
- }
26
-
27
- export { supports };
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var transforms = require('./transforms.cjs.js');
6
-
7
- function getStyleName(key) {
8
- if (transforms.transformAlias[key])
9
- key = transforms.transformAlias[key];
10
- return transforms.isTransform(key) ? transforms.asTransformCssVar(key) : key;
11
- }
12
-
13
- exports.getStyleName = getStyleName;
@@ -1,9 +0,0 @@
1
- import { isTransform, asTransformCssVar, transformAlias } from './transforms.es.js';
2
-
3
- function getStyleName(key) {
4
- if (transformAlias[key])
5
- key = transformAlias[key];
6
- return isTransform(key) ? asTransformCssVar(key) : key;
7
- }
8
-
9
- export { getStyleName };
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function hydrateKeyframes(keyframes, readInitialValue) {
6
- for (let i = 0; i < keyframes.length; i++) {
7
- if (keyframes[i] === null) {
8
- keyframes[i] = i ? keyframes[i - 1] : readInitialValue();
9
- }
10
- }
11
- return keyframes;
12
- }
13
- const keyframesList = (keyframes) => Array.isArray(keyframes) ? keyframes : [keyframes];
14
-
15
- exports.hydrateKeyframes = hydrateKeyframes;
16
- exports.keyframesList = keyframesList;