anim-engine 0.2.0 → 0.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.
package/README.md CHANGED
@@ -231,8 +231,8 @@ For more complex sequences, use `createTimeline`:
231
231
  import { createTimeline } from "anim-engine";
232
232
 
233
233
  const flash = createTimeline([
234
- { at: 0, keyframe: { keyframes: [{ value: 0 }, { value: 1, gap: 300 }] } },
235
- { gap: 0, keyframe: { keyframes: [{ value: 1 }, { value: 0, gap: 300 }] } },
234
+ { at: 0, animation: { keyframes: [{ value: 0 }, { value: 1, gap: 300 }] } },
235
+ { gap: 0, animation: { keyframes: [{ value: 1 }, { value: 0, gap: 300 }] } },
236
236
  ]);
237
237
  await flash.play();
238
238
  ```
@@ -248,14 +248,14 @@ const timeline = createTimeline(
248
248
  [
249
249
  {
250
250
  at: 0,
251
- keyframe: {
251
+ animation: {
252
252
  keyframes: [{ value: 0 }, { value: 1, gap: 500 }],
253
253
  onUpdate: (v) => (sprite.alpha = v),
254
254
  },
255
255
  },
256
256
  {
257
257
  at: 0,
258
- keyframe: {
258
+ animation: {
259
259
  keyframes: [{ value: -100 }, { value: 0, gap: 800, ease: "outBack" }],
260
260
  onUpdate: (v) => (sprite.x = v),
261
261
  },
@@ -273,8 +273,8 @@ timeline.play();
273
273
 
274
274
  ```ts
275
275
  type TimelineLayer =
276
- | { keyframe: KeyframedAnimationOptions; at: DynamicValue }
277
- | { keyframe: KeyframedAnimationOptions; gap: number };
276
+ | { animation: KeyframedAnimationOptions; at: DynamicValue }
277
+ | { animation: KeyframedAnimationOptions; gap: number };
278
278
  ```
279
279
 
280
280
  | Parameter | Type | Description |
@@ -676,7 +676,7 @@ requestAnimationFrame(gameLoop);
676
676
  | `AnimationOptions` | Single tween or keyframe animation options (discriminated union) |
677
677
  | `Keyframe` | `{ value, gap?, ease? }` |
678
678
  | `KeyframedAnimationOptions` | `{ keyframes: Keyframe[], onStarted?, onUpdate?, onProgress?, onEnded? }` |
679
- | `TimelineLayer` | `{ keyframe: KeyframedAnimationOptions; at: DynamicValue } \| { keyframe: KeyframedAnimationOptions; gap: number }` |
679
+ | `TimelineLayer` | `{ animation: KeyframedAnimationOptions; at: DynamicValue } \| { animation: KeyframedAnimationOptions; gap: number }` |
680
680
  | `SpringOptions` | `to`, `stiffness`, `damping`, `mass`, `precision?`, `onUpdate`, `onEnded` |
681
681
  | `SmoothDampOptions` | `to`, `smoothTimeMs`, `maxSpeed?`, `precision?`, `onUpdate`, `onEnded` |
682
682
  | `LerpOptions` | `to`, `smoothTimeMs`, `precision?`, `onUpdate`, `onEnded` |
@@ -1,10 +1,10 @@
1
1
  import { KeyframedAnimationOptions } from '../animation/create-animation';
2
2
  import { AnimationStatus, DynamicValue } from '../shared/types';
3
3
  export type TimelineLayer = {
4
- keyframe: KeyframedAnimationOptions;
4
+ animation: KeyframedAnimationOptions;
5
5
  at: DynamicValue;
6
6
  } | {
7
- keyframe: KeyframedAnimationOptions;
7
+ animation: KeyframedAnimationOptions;
8
8
  gap: number;
9
9
  };
10
10
  export type Timeline = {
@@ -10,7 +10,7 @@ var buildFromConfigs = (rawLayers) => {
10
10
  let previousEndAt = 0;
11
11
  for (const layer of rawLayers) {
12
12
  const startAt = "at" in layer ? resolveValue(layer.at) : previousEndAt + layer.gap;
13
- const resolvedKeyframes = layer.keyframe.keyframes.map((kf, j) => ({
13
+ const resolvedKeyframes = layer.animation.keyframes.map((kf, j) => ({
14
14
  value: resolveValue(kf.value),
15
15
  gap: j === 0 ? 0 : resolveValue(kf.gap ?? 0),
16
16
  easeFn: resolveEasing(kf.ease ?? "inOutSine")
@@ -19,10 +19,10 @@ var buildFromConfigs = (rawLayers) => {
19
19
  for (let i = 1; i < resolvedKeyframes.length; i++) layerDuration += resolvedKeyframes[i].gap;
20
20
  const runner = createKeyframeRunner({
21
21
  keyframes: resolvedKeyframes,
22
- onStarted: layer.keyframe.onStarted,
23
- onUpdate: layer.keyframe.onUpdate,
24
- onProgress: layer.keyframe.onProgress,
25
- onEnded: layer.keyframe.onEnded
22
+ onStarted: layer.animation.onStarted,
23
+ onUpdate: layer.animation.onUpdate,
24
+ onProgress: layer.animation.onProgress,
25
+ onEnded: layer.animation.onEnded
26
26
  });
27
27
  activeLayers.push({
28
28
  startAt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anim-engine",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "description": "JavaScript library for animating numbers",
6
6
  "license": "MIT",