motion 10.2.1 → 10.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +1 -0
  3. package/dist/main.cjs.js +2 -0
  4. package/dist/main.es.js +1 -0
  5. package/dist/motion.min.js +1 -1
  6. package/dist/motion.umd.js +426 -280
  7. package/dist/size-animate-dom.js +1 -1
  8. package/dist/size-animate-style.js +1 -1
  9. package/dist/size-react.js +1 -1
  10. package/dist/size-spring.js +1 -1
  11. package/dist/size-timeline-dom.js +1 -1
  12. package/dist/size-webpack-animate.js +1 -1
  13. package/dist/targets/dom/animate-style.cjs.js +135 -134
  14. package/dist/targets/dom/animate-style.es.js +137 -136
  15. package/dist/targets/dom/animate.cjs.js +15 -4
  16. package/dist/targets/dom/animate.es.js +16 -5
  17. package/dist/targets/dom/data.cjs.js +4 -3
  18. package/dist/targets/dom/data.es.js +4 -3
  19. package/dist/targets/dom/style.cjs.js +1 -1
  20. package/dist/targets/dom/style.es.js +2 -2
  21. package/dist/targets/dom/timeline/index.cjs.js +7 -6
  22. package/dist/targets/dom/timeline/index.es.js +8 -7
  23. package/dist/targets/dom/timeline/utils/calc-time.cjs.js +3 -1
  24. package/dist/targets/dom/timeline/utils/calc-time.es.js +3 -1
  25. package/dist/targets/dom/utils/apply.cjs.js +4 -8
  26. package/dist/targets/dom/utils/apply.es.js +3 -7
  27. package/dist/targets/dom/utils/controls.cjs.js +6 -2
  28. package/dist/targets/dom/utils/controls.es.js +6 -2
  29. package/dist/targets/dom/utils/css-var.cjs.js +2 -2
  30. package/dist/targets/dom/utils/css-var.es.js +3 -3
  31. package/dist/targets/dom/utils/easing.cjs.js +4 -2
  32. package/dist/targets/dom/utils/easing.es.js +4 -2
  33. package/dist/targets/dom/utils/feature-detection.cjs.js +4 -4
  34. package/dist/targets/dom/utils/feature-detection.es.js +4 -4
  35. package/dist/targets/dom/utils/get-style-name.cjs.js +13 -0
  36. package/dist/targets/dom/utils/get-style-name.es.js +9 -0
  37. package/dist/targets/dom/utils/keyframes.cjs.js +2 -4
  38. package/dist/targets/dom/utils/keyframes.es.js +2 -4
  39. package/dist/targets/dom/utils/options.cjs.js +1 -1
  40. package/dist/targets/dom/utils/options.es.js +1 -1
  41. package/dist/targets/dom/utils/stop-animation.cjs.js +2 -0
  42. package/dist/targets/dom/utils/stop-animation.es.js +2 -0
  43. package/dist/targets/dom/utils/transforms.cjs.js +10 -7
  44. package/dist/targets/dom/utils/transforms.es.js +10 -7
  45. package/dist/targets/js/{animate-number.cjs.js → NumberAnimation.cjs.js} +40 -29
  46. package/dist/targets/js/{animate-number.es.js → NumberAnimation.es.js} +40 -28
  47. package/dist/targets/js/easing/glide/generator.cjs.js +99 -0
  48. package/dist/targets/js/easing/glide/generator.es.js +95 -0
  49. package/dist/targets/js/easing/glide/index.cjs.js +10 -0
  50. package/dist/targets/js/easing/glide/index.es.js +6 -0
  51. package/dist/targets/js/easing/spring/generator.cjs.js +9 -4
  52. package/dist/targets/js/easing/spring/generator.es.js +9 -5
  53. package/dist/targets/js/easing/spring/index.cjs.js +2 -62
  54. package/dist/targets/js/easing/spring/index.es.js +2 -62
  55. package/dist/targets/js/easing/utils/create-generator-easing.cjs.js +71 -0
  56. package/dist/targets/js/easing/utils/create-generator-easing.es.js +67 -0
  57. package/dist/targets/js/easing/utils/has-reached-target.cjs.js +10 -0
  58. package/dist/targets/js/easing/utils/has-reached-target.es.js +6 -0
  59. package/dist/targets/js/easing/utils/pregenerate-keyframes.cjs.js +13 -10
  60. package/dist/targets/js/easing/utils/pregenerate-keyframes.es.js +13 -10
  61. package/dist/targets/react/hooks/use-animation.cjs.js +5 -2
  62. package/dist/targets/react/hooks/use-animation.es.js +5 -2
  63. package/dist/targets/react/utils/keyframes.cjs.js +5 -3
  64. package/dist/targets/react/utils/keyframes.es.js +6 -4
  65. package/dist/utils/is-number.cjs.js +7 -0
  66. package/dist/utils/is-number.es.js +3 -0
  67. package/dist/utils/stagger.cjs.js +2 -1
  68. package/dist/utils/stagger.es.js +2 -1
  69. package/package.json +4 -10
  70. package/types/index.d.ts +1 -0
  71. package/types/targets/dom/animate-style.d.ts +2 -2
  72. package/types/targets/dom/style.d.ts +1 -1
  73. package/types/targets/dom/types.d.ts +8 -4
  74. package/types/targets/dom/utils/apply.d.ts +3 -2
  75. package/types/targets/dom/utils/controls.d.ts +3 -3
  76. package/types/targets/dom/utils/get-style-name.d.ts +1 -0
  77. package/types/targets/dom/utils/keyframes.d.ts +1 -1
  78. package/types/targets/dom/utils/stop-animation.d.ts +1 -1
  79. package/types/targets/dom/utils/transforms.d.ts +2 -2
  80. package/types/targets/js/{animate-number.d.ts → NumberAnimation.d.ts} +2 -3
  81. package/types/targets/js/easing/glide/generator.d.ts +5 -0
  82. package/types/targets/js/easing/glide/index.d.ts +2 -0
  83. package/types/targets/js/easing/glide/types.d.ts +14 -0
  84. package/types/targets/js/easing/spring/generator.d.ts +1 -0
  85. package/types/targets/js/easing/spring/index.d.ts +1 -2
  86. package/types/targets/js/easing/utils/create-generator-easing.d.ts +3 -0
  87. package/types/targets/js/easing/utils/has-reached-target.d.ts +1 -0
  88. package/types/targets/js/easing/utils/pregenerate-keyframes.d.ts +1 -1
  89. package/types/targets/js/types.d.ts +3 -0
  90. package/types/utils/is-number.d.ts +1 -0
@@ -0,0 +1,67 @@
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 };
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1,6 @@
1
+ function hasReachedTarget(origin, target, current) {
2
+ return ((origin < target && current >= target) ||
3
+ (origin > target && current <= target));
4
+ }
5
+
6
+ export { hasReachedTarget };
@@ -3,24 +3,27 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const timeStep = 10;
6
- const maxDuration = 3000;
7
- function pregenerateKeyframes(generator, origin, target) {
8
- const keyframes = [];
6
+ const maxDuration = 10000;
7
+ function pregenerateKeyframes(generator) {
9
8
  let overshootDuration = undefined;
10
- let timestamp = 0;
9
+ let timestamp = timeStep;
11
10
  let state = generator.next(0);
11
+ const keyframes = [state.value];
12
12
  while (!state.done && timestamp < maxDuration) {
13
13
  state = generator.next(timestamp);
14
- keyframes.push(state.done ? target : state.value);
15
- if (overshootDuration === undefined) {
16
- if ((origin < target && state.value >= target) ||
17
- (origin > target && state.value <= target)) {
18
- overshootDuration = timestamp;
19
- }
14
+ keyframes.push(state.done ? state.target : state.value);
15
+ if (overshootDuration === undefined && state.hasReachedTarget) {
16
+ overshootDuration = timestamp;
20
17
  }
21
18
  timestamp += timeStep;
22
19
  }
23
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);
24
27
  return {
25
28
  keyframes,
26
29
  duration: duration / 1000,
@@ -1,22 +1,25 @@
1
1
  const timeStep = 10;
2
- const maxDuration = 3000;
3
- function pregenerateKeyframes(generator, origin, target) {
4
- const keyframes = [];
2
+ const maxDuration = 10000;
3
+ function pregenerateKeyframes(generator) {
5
4
  let overshootDuration = undefined;
6
- let timestamp = 0;
5
+ let timestamp = timeStep;
7
6
  let state = generator.next(0);
7
+ const keyframes = [state.value];
8
8
  while (!state.done && timestamp < maxDuration) {
9
9
  state = generator.next(timestamp);
10
- keyframes.push(state.done ? target : state.value);
11
- if (overshootDuration === undefined) {
12
- if ((origin < target && state.value >= target) ||
13
- (origin > target && state.value <= target)) {
14
- overshootDuration = timestamp;
15
- }
10
+ keyframes.push(state.done ? state.target : state.value);
11
+ if (overshootDuration === undefined && state.hasReachedTarget) {
12
+ overshootDuration = timestamp;
16
13
  }
17
14
  timestamp += timeStep;
18
15
  }
19
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);
20
23
  return {
21
24
  keyframes,
22
25
  duration: duration / 1000,
@@ -28,11 +28,14 @@ function useAnimation(ref, initial, target, options$1, onStart, onComplete) {
28
28
  });
29
29
  if (Object.keys(targetKeyframe).length && ref.current) {
30
30
  onStart === null || onStart === void 0 ? void 0 : onStart(targetKeyframe);
31
- const animations = [];
31
+ const animationFactories = [];
32
32
  for (const key in targetKeyframe) {
33
33
  const animation = animateStyle.animateStyle(ref.current, key, targetKeyframe[key], options.getOptions(options$1, key));
34
- animation && animations.push(animation);
34
+ animationFactories.push(animation);
35
35
  }
36
+ const animations = animationFactories
37
+ .map((factory) => factory())
38
+ .filter(Boolean);
36
39
  Promise.all(animations.map((animation) => animation.finished))
37
40
  .then(() => onComplete === null || onComplete === void 0 ? void 0 : onComplete(targetKeyframe))
38
41
  .catch(noop.noop);
@@ -24,11 +24,14 @@ function useAnimation(ref, initial, target, options, onStart, onComplete) {
24
24
  });
25
25
  if (Object.keys(targetKeyframe).length && ref.current) {
26
26
  onStart === null || onStart === void 0 ? void 0 : onStart(targetKeyframe);
27
- const animations = [];
27
+ const animationFactories = [];
28
28
  for (const key in targetKeyframe) {
29
29
  const animation = animateStyle(ref.current, key, targetKeyframe[key], getOptions(options, key));
30
- animation && animations.push(animation);
30
+ animationFactories.push(animation);
31
31
  }
32
+ const animations = animationFactories
33
+ .map((factory) => factory())
34
+ .filter(Boolean);
32
35
  Promise.all(animations.map((animation) => animation.finished))
33
36
  .then(() => onComplete === null || onComplete === void 0 ? void 0 : onComplete(targetKeyframe))
34
37
  .catch(noop);
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var isNumber = require('../../../utils/is-number.cjs.js');
5
6
  var transforms = require('../../dom/utils/transforms.cjs.js');
6
7
 
7
8
  function convertKeyframesToStyles(keyframes) {
@@ -20,10 +21,11 @@ function convertKeyframesToStyles(keyframes) {
20
21
  * If this is a number and we have a default value type, convert the number
21
22
  * to this type.
22
23
  */
23
- const definition = transforms.transformPropertyDefinitions.get(key);
24
+ const definition = transforms.transformDefinitions.get(key);
24
25
  if (definition) {
25
- initialKeyframe =
26
- typeof value === "number" ? definition.toDefaultUnit(value) : value;
26
+ initialKeyframe = isNumber.isNumber(value)
27
+ ? definition.toDefaultUnit(value)
28
+ : value;
27
29
  }
28
30
  initialKeyframes[key] = initialKeyframe;
29
31
  }
@@ -1,4 +1,5 @@
1
- import { isTransform, transformAlias, asTransformCssVar, transformPropertyDefinitions, buildTransformTemplate } from '../../dom/utils/transforms.es.js';
1
+ import { isNumber } from '../../../utils/is-number.es.js';
2
+ import { isTransform, transformAlias, asTransformCssVar, transformDefinitions, buildTransformTemplate } from '../../dom/utils/transforms.es.js';
2
3
 
3
4
  function convertKeyframesToStyles(keyframes) {
4
5
  const initialKeyframes = {};
@@ -16,10 +17,11 @@ function convertKeyframesToStyles(keyframes) {
16
17
  * If this is a number and we have a default value type, convert the number
17
18
  * to this type.
18
19
  */
19
- const definition = transformPropertyDefinitions.get(key);
20
+ const definition = transformDefinitions.get(key);
20
21
  if (definition) {
21
- initialKeyframe =
22
- typeof value === "number" ? definition.toDefaultUnit(value) : value;
22
+ initialKeyframe = isNumber(value)
23
+ ? definition.toDefaultUnit(value)
24
+ : value;
23
25
  }
24
26
  initialKeyframes[key] = initialKeyframe;
25
27
  }
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const isNumber = (value) => typeof value === "number";
6
+
7
+ exports.isNumber = isNumber;
@@ -0,0 +1,3 @@
1
+ const isNumber = (value) => typeof value === "number";
2
+
3
+ export { isNumber };
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var getFunction = require('../targets/js/easing/utils/get-function.cjs.js');
6
+ var isNumber = require('./is-number.cjs.js');
6
7
 
7
8
  function stagger(duration = 0.1, { start = 0, from = 0, easing } = {}) {
8
9
  return (i, total) => {
9
- const fromIndex = typeof from === "number" ? from : getFromIndex(from, total);
10
+ const fromIndex = isNumber.isNumber(from) ? from : getFromIndex(from, total);
10
11
  const distance = Math.abs(fromIndex - i);
11
12
  let delay = duration * distance;
12
13
  if (easing) {
@@ -1,8 +1,9 @@
1
1
  import { getEasingFunction } from '../targets/js/easing/utils/get-function.es.js';
2
+ import { isNumber } from './is-number.es.js';
2
3
 
3
4
  function stagger(duration = 0.1, { start = 0, from = 0, easing } = {}) {
4
5
  return (i, total) => {
5
- const fromIndex = typeof from === "number" ? from : getFromIndex(from, total);
6
+ const fromIndex = isNumber(from) ? from : getFromIndex(from, total);
6
7
  const distance = Math.abs(fromIndex - i);
7
8
  let delay = duration * distance;
8
9
  if (easing) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion",
3
- "version": "10.2.1",
3
+ "version": "10.3.0",
4
4
  "description": "The Motion library for the web",
5
5
  "author": "Matt Perry",
6
6
  "main": "dist/main.cjs.js",
@@ -70,12 +70,6 @@
70
70
  "@rollup/plugin-commonjs": "^19.0.0",
71
71
  "@rollup/plugin-node-resolve": "^11.2.0",
72
72
  "@rollup/plugin-replace": "^2.4.1",
73
- "@storybook/addon-actions": "^6.2.9",
74
- "@storybook/addon-essentials": "^6.2.9",
75
- "@storybook/addon-links": "^6.2.9",
76
- "@storybook/node-logger": "^6.2.9",
77
- "@storybook/preset-create-react-app": "^3.1.7",
78
- "@storybook/react": "^6.2.9",
79
73
  "@testing-library/dom": "^8.1.0",
80
74
  "@testing-library/jest-dom": "^5.14.1",
81
75
  "@testing-library/react": "^12.0.0",
@@ -102,7 +96,7 @@
102
96
  "ts-loader": "^8.3.0",
103
97
  "typescript": "^4.4.0-beta",
104
98
  "web-animations-js": "^2.3.2",
105
- "webpack": "^4.46.0",
99
+ "webpack": "^5.58.1",
106
100
  "webpack-cli": "^4.8.0"
107
101
  },
108
102
  "husky": {
@@ -140,7 +134,7 @@
140
134
  },
141
135
  {
142
136
  "path": "./dist/size-spring.js",
143
- "maxSize": "0.95 kB"
137
+ "maxSize": "1 kB"
144
138
  },
145
139
  {
146
140
  "path": "./dist/size-react.js",
@@ -148,7 +142,7 @@
148
142
  },
149
143
  {
150
144
  "path": "./dist/size-webpack-animate.js",
151
- "maxSize": "3.6 kB"
145
+ "maxSize": "3.4 kB"
152
146
  }
153
147
  ]
154
148
  }
package/types/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export { animateStyle } from "./targets/dom/animate-style.js";
3
3
  export { timeline } from "./targets/dom/timeline/index.js";
4
4
  export { stagger } from "./utils/stagger.js";
5
5
  export { spring } from "./targets/js/easing/spring/index.js";
6
+ export { glide } from "./targets/js/easing/glide/index.js";
6
7
  export * from "./targets/dom/types";
@@ -1,2 +1,2 @@
1
- import { AnimationOptions, BasicAnimationControls, ValueKeyframesDefinition } from "./types";
2
- export declare function animateStyle(element: Element, name: string, keyframesDefinition: ValueKeyframesDefinition, options?: AnimationOptions): BasicAnimationControls | undefined;
1
+ import { AnimationFactory, AnimationOptions, ValueKeyframesDefinition } from "./types";
2
+ export declare function animateStyle(element: Element, key: string, keyframesDefinition: ValueKeyframesDefinition, options?: AnimationOptions): AnimationFactory;
@@ -1,3 +1,3 @@
1
1
  export declare const style: {
2
- get: (element: Element, name: string) => any;
2
+ get: (element: Element, name: string) => string | undefined;
3
3
  };
@@ -1,14 +1,17 @@
1
1
  import { OptionResolver } from "../../utils/stagger";
2
- import { AnimationGenerator } from "../js/types";
2
+ import { AnimationGenerator, AnimationGeneratorState } from "../js/types";
3
3
  import { NextTime } from "./timeline/types";
4
4
  export interface AnimationData {
5
- activeTransforms: string[];
6
- activeAnimations: {
5
+ transforms: string[];
6
+ animations: {
7
7
  [key: string]: BasicAnimationControls | undefined;
8
8
  };
9
- activeGenerators: {
9
+ generators: {
10
10
  [key: string]: AnimationGenerator | undefined;
11
11
  };
12
+ prevGeneratorState: {
13
+ [key: string]: AnimationGeneratorState | undefined;
14
+ };
12
15
  }
13
16
  export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
14
17
  export declare type AcceptedElements = Element | Element[] | NodeListOf<Element> | string;
@@ -108,3 +111,4 @@ export interface CssPropertyDefinition {
108
111
  export declare type CssPropertyDefinitionMap = {
109
112
  [key: string]: CssPropertyDefinition;
110
113
  };
114
+ export declare type AnimationFactory = () => BasicAnimationControls | undefined;
@@ -1,2 +1,3 @@
1
- export declare const createCssVariableRenderer: (element: Element, name: string) => (latest: string | number) => void;
2
- export declare const createStyleRenderer: (element: Element, name: string) => (latest: string | number) => string | number;
1
+ export declare type RendererFactory = (element: Element, name: string) => (latest: string | number) => void;
2
+ export declare const cssVariableRenderer: RendererFactory;
3
+ export declare const styleRenderer: RendererFactory;
@@ -1,10 +1,10 @@
1
- import { AnimationControls, AnimationWithCommitStyles } from "../types";
1
+ import { AnimationControls, AnimationFactory, AnimationWithCommitStyles } from "../types";
2
2
  interface AnimationState {
3
- duration: number;
4
3
  animations: AnimationWithCommitStyles[];
4
+ duration: number;
5
5
  finished?: Promise<any>;
6
6
  }
7
- export declare const createAnimationControls: (animations: AnimationWithCommitStyles[], duration: number) => AnimationControls;
7
+ export declare const createAnimations: (animationFactory: AnimationFactory[], duration: number) => AnimationControls;
8
8
  export declare const controls: {
9
9
  get: (target: AnimationState, key: string) => number | Promise<any> | (() => void) | undefined;
10
10
  set: (target: AnimationState, key: string, value: number) => boolean;
@@ -0,0 +1 @@
1
+ export declare function getStyleName(key: string): string;
@@ -1,3 +1,3 @@
1
1
  import { UnresolvedValueKeyframe, ValueKeyframe } from "../types";
2
- export declare function hydrateKeyframes(keyframes: UnresolvedValueKeyframe[], element: Element, name: string): ValueKeyframe[];
2
+ export declare function hydrateKeyframes(keyframes: UnresolvedValueKeyframe[], readInitialValue: () => string | number): ValueKeyframe[];
3
3
  export declare const keyframesList: (keyframes: UnresolvedValueKeyframe | UnresolvedValueKeyframe[]) => UnresolvedValueKeyframe[];
@@ -3,4 +3,4 @@ export interface WithCommitStyles {
3
3
  commitStyles: VoidFunction;
4
4
  cancel: VoidFunction;
5
5
  }
6
- export declare function stopAnimation(animation: BasicAnimationControls): void;
6
+ export declare function stopAnimation(animation?: BasicAnimationControls): void;
@@ -9,7 +9,7 @@ export declare const transformAlias: {
9
9
  y: string;
10
10
  z: string;
11
11
  };
12
- export declare const transformPropertyDefinitions: Map<string, CssPropertyDefinition>;
12
+ export declare const transformDefinitions: Map<string, CssPropertyDefinition>;
13
13
  export declare const asTransformCssVar: (name: string) => string;
14
14
  /**
15
15
  * A function to use with Array.sort to sort transform keys by their default order.
@@ -17,4 +17,4 @@ export declare const asTransformCssVar: (name: string) => string;
17
17
  export declare const compareTransformOrder: (a: string, b: string) => number;
18
18
  export declare const isTransform: (name: string) => boolean;
19
19
  export declare const addTransformToElement: (element: HTMLElement, name: string) => void;
20
- export declare const buildTransformTemplate: (activeTransforms: string[]) => string;
20
+ export declare const buildTransformTemplate: (transforms: string[]) => string;
@@ -1,5 +1,5 @@
1
1
  import { AnimationControls, AnimationOptions } from "../dom/types";
2
- export declare class Animation implements Omit<AnimationControls, "stop" | "duration"> {
2
+ export declare class NumberAnimation implements Omit<AnimationControls, "stop" | "duration"> {
3
3
  private resolve;
4
4
  private reject;
5
5
  private startTime;
@@ -9,7 +9,7 @@ export declare class Animation implements Omit<AnimationControls, "stop" | "dura
9
9
  private t;
10
10
  private cancelT;
11
11
  playState: AnimationPlayState;
12
- constructor(output: (v: number) => void, keyframes: number[], { easing, duration, delay, endDelay, repeat, offset, direction, }: AnimationOptions);
12
+ constructor(output: (v: number) => void, keyframes?: number[], { easing, duration, delay, endDelay, repeat, offset, direction, }?: AnimationOptions);
13
13
  finished: Promise<unknown>;
14
14
  play(): void;
15
15
  pause(): void;
@@ -22,4 +22,3 @@ export declare class Animation implements Omit<AnimationControls, "stop" | "dura
22
22
  get playbackRate(): number;
23
23
  set playbackRate(rate: number);
24
24
  }
25
- export declare function animateNumber(output: (v: number) => void, keyframes?: number[], options?: AnimationOptions): Animation;
@@ -0,0 +1,5 @@
1
+ import { GlideOptions } from "./types";
2
+ import { AnimationGeneratorState } from "../../types";
3
+ export declare const createGlideGenerator: ({ from, velocity, power, decay, bounceDamping, bounceStiffness, changeTarget, min, max, restDistance, restSpeed, }: GlideOptions) => {
4
+ next: (t: number) => AnimationGeneratorState;
5
+ };
@@ -0,0 +1,2 @@
1
+ import { GlideOptions } from "./types";
2
+ export declare const glide: (options?: GlideOptions) => import("../../../..").CustomEasing;
@@ -0,0 +1,14 @@
1
+ export interface GlideOptions {
2
+ power?: number;
3
+ decay?: number;
4
+ changeTarget?: (v: number) => number;
5
+ max?: number;
6
+ min?: number;
7
+ bounceDamping?: number;
8
+ bounceStiffness?: number;
9
+ restSpeed?: number;
10
+ restDistance?: number;
11
+ from?: number;
12
+ to?: number;
13
+ velocity?: number;
14
+ }
@@ -3,3 +3,4 @@ import { SpringOptions } from "./types";
3
3
  export declare const calcDampingRatio: (stiffness?: number, damping?: number, mass?: number) => number;
4
4
  export declare const calcAngularFreq: (undampedFreq: number, dampingRatio: number) => number;
5
5
  export declare const createSpringGenerator: ({ stiffness, damping, mass, from, to, velocity, restSpeed, restDistance, }?: SpringOptions) => AnimationGenerator;
6
+ export declare function calcVelocity(resolveValue: (v: number) => number, t: number, current: number): number;
@@ -1,3 +1,2 @@
1
1
  import { SpringOptions } from "./types";
2
- import { CustomEasing } from "../../../..";
3
- export declare function spring(options?: SpringOptions): CustomEasing;
2
+ export declare const spring: (options?: SpringOptions) => import("../../../..").CustomEasing;
@@ -0,0 +1,3 @@
1
+ import { CustomEasing } from "../../../..";
2
+ import { AnimationGeneratorFactory } from "../../types";
3
+ export declare function createGeneratorEasing<Options extends {} = {}>(createGenerator: AnimationGeneratorFactory<Options>): (options?: Options) => CustomEasing;
@@ -0,0 +1 @@
1
+ export declare function hasReachedTarget(origin: number, target: number, current: number): boolean;
@@ -4,4 +4,4 @@ export interface KeyframesMetadata {
4
4
  duration: number;
5
5
  overshootDuration: number;
6
6
  }
7
- export declare function pregenerateKeyframes(generator: AnimationGenerator, origin: number, target: number): KeyframesMetadata;
7
+ export declare function pregenerateKeyframes(generator: AnimationGenerator): KeyframesMetadata;
@@ -1,9 +1,12 @@
1
1
  export declare type EasingFunction = (v: number) => number;
2
2
  export declare type AnimationGeneratorState = {
3
3
  value: number;
4
+ target: number;
4
5
  done: boolean;
5
6
  velocity: number;
7
+ hasReachedTarget: boolean;
6
8
  };
7
9
  export declare type AnimationGenerator = {
8
10
  next: (t: number) => AnimationGeneratorState;
9
11
  };
12
+ export declare type AnimationGeneratorFactory<Options> = (options: Options) => AnimationGenerator;
@@ -0,0 +1 @@
1
+ export declare const isNumber: (value: unknown) => value is number;