Comparing version 1.4.0 to 1.5.0-rc2
@@ -38,2 +38,4 @@ import EventEmitter from 'eventemitter3'; | ||
private hasCompleted; | ||
private promiseResolver?; | ||
private currentPromise?; | ||
constructor({ from, to, duration, easing, delay, direction, loop, }: AnimateOptions); | ||
@@ -47,4 +49,5 @@ private isValidAnimatableValue; | ||
stop(): this; | ||
promise(): Promise<void>; | ||
set(options: SetOptions): void; | ||
} | ||
export {}; |
@@ -67,2 +67,6 @@ "use strict"; | ||
this.emit('complete'); | ||
if (this.promiseResolver) { | ||
this.promiseResolver(); | ||
this.promiseResolver = undefined; | ||
} | ||
} | ||
@@ -150,2 +154,5 @@ } | ||
this.process = framesync_1.default.update(this.tick, true); | ||
this.currentPromise = new Promise((resolve) => { | ||
this.promiseResolver = resolve; | ||
}); | ||
return this; | ||
@@ -160,5 +167,17 @@ } | ||
this.emit('stop'); | ||
if (this.promiseResolver) { | ||
this.promiseResolver(); | ||
this.promiseResolver = undefined; | ||
} | ||
} | ||
return this; | ||
} | ||
promise() { | ||
if (!this.currentPromise) { | ||
this.currentPromise = new Promise((resolve) => { | ||
this.promiseResolver = resolve; | ||
}); | ||
} | ||
return this.currentPromise; | ||
} | ||
set(options) { | ||
@@ -165,0 +184,0 @@ if (options.from !== undefined) { |
@@ -12,2 +12,4 @@ import EventEmitter from 'eventemitter3'; | ||
private completedAnimations; | ||
private promiseResolver?; | ||
private currentPromise?; | ||
constructor({ animates, blendFunction }: BlendOptions); | ||
@@ -23,3 +25,4 @@ private updateHandler; | ||
}): void; | ||
promise(): Promise<void>; | ||
} | ||
export {}; |
@@ -20,2 +20,6 @@ "use strict"; | ||
this.emit('complete'); | ||
if (this.promiseResolver) { | ||
this.promiseResolver(); | ||
this.promiseResolver = undefined; | ||
} | ||
} | ||
@@ -35,2 +39,5 @@ }; | ||
this.emit('start'); | ||
this.currentPromise = new Promise((resolve) => { | ||
this.promiseResolver = resolve; | ||
}); | ||
return this; | ||
@@ -41,2 +48,6 @@ } | ||
this.emit('stop'); | ||
if (this.promiseResolver) { | ||
this.promiseResolver(); | ||
this.promiseResolver = undefined; | ||
} | ||
return this; | ||
@@ -57,3 +68,11 @@ } | ||
} | ||
promise() { | ||
if (!this.currentPromise) { | ||
this.currentPromise = new Promise((resolve) => { | ||
this.promiseResolver = resolve; | ||
}); | ||
} | ||
return this.currentPromise; | ||
} | ||
} | ||
exports.Blend = Blend; |
@@ -7,2 +7,4 @@ import EventEmitter from 'eventemitter3'; | ||
private animations; | ||
private promiseResolver?; | ||
private currentPromise?; | ||
constructor(); | ||
@@ -14,3 +16,4 @@ add(animation: AnimationType): void; | ||
stop(): void; | ||
promise(): Promise<void>; | ||
} | ||
export {}; |
@@ -31,2 +31,6 @@ "use strict"; | ||
this.emit('complete'); // Emit complete event when all animations in the queue have completed | ||
if (this.promiseResolver) { | ||
this.promiseResolver(); | ||
this.promiseResolver = undefined; | ||
} | ||
} | ||
@@ -49,4 +53,16 @@ } | ||
} | ||
if (this.promiseResolver) { | ||
this.promiseResolver(); | ||
this.promiseResolver = undefined; | ||
} | ||
} | ||
promise() { | ||
if (!this.currentPromise) { | ||
this.currentPromise = new Promise((resolve) => { | ||
this.promiseResolver = resolve; | ||
}); | ||
} | ||
return this.currentPromise; | ||
} | ||
} | ||
exports.Queue = Queue; |
@@ -14,2 +14,4 @@ import EventEmitter from 'eventemitter3'; | ||
private activeAnimates; | ||
private promiseResolver?; | ||
private currentPromise?; | ||
constructor({ items, parallel }: SequenceOptions); | ||
@@ -20,3 +22,4 @@ private handleComplete; | ||
stop(): this; | ||
promise(): Promise<void>; | ||
} | ||
export {}; |
@@ -17,2 +17,6 @@ "use strict"; | ||
this.emit('complete'); | ||
if (this.promiseResolver) { | ||
this.promiseResolver(); | ||
this.promiseResolver = undefined; | ||
} | ||
} | ||
@@ -24,2 +28,6 @@ else if (!this.parallel) { | ||
this.emit('complete'); | ||
if (this.promiseResolver) { | ||
this.promiseResolver(); | ||
this.promiseResolver = undefined; | ||
} | ||
} | ||
@@ -49,2 +57,6 @@ }; | ||
this.emit('complete'); | ||
if (this.promiseResolver) { | ||
this.promiseResolver(); | ||
this.promiseResolver = undefined; | ||
} | ||
} | ||
@@ -62,2 +74,5 @@ }; | ||
this.next(); | ||
this.currentPromise = new Promise((resolve) => { | ||
this.promiseResolver = resolve; | ||
}); | ||
return this; | ||
@@ -75,5 +90,17 @@ } | ||
this.emit('stop'); | ||
if (this.promiseResolver) { | ||
this.promiseResolver(); | ||
this.promiseResolver = undefined; | ||
} | ||
return this; | ||
} | ||
promise() { | ||
if (!this.currentPromise) { | ||
this.currentPromise = new Promise((resolve) => { | ||
this.promiseResolver = resolve; | ||
}); | ||
} | ||
return this.currentPromise; | ||
} | ||
} | ||
exports.Sequence = Sequence; |
{ | ||
"name": "nimate", | ||
"version": "1.4.0", | ||
"version": "1.5.0-rc2", | ||
"description": "A simple, flexible animation library.", | ||
@@ -17,3 +17,3 @@ "main": "dist/index.js", | ||
"type": "git", | ||
"url": "https://github.com/4ver/nimate.git" | ||
"url": "git+https://github.com/4ver/nimate.git" | ||
}, | ||
@@ -20,0 +20,0 @@ "keywords": [ |
# nimate | ||
[![npm](https://img.shields.io/npm/v/nimate)](https://www.npmjs.com/package/nimate) ![issues](https://img.shields.io/github/issues/4ver/nimate) ![stars](https://img.shields.io/github/stars/4ver/nimate) | ||
[![npm](https://img.shields.io/npm/v/nimate)](https://www.npmjs.com/package/nimate) | ||
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2F4ver%2Fnimate.svg?type=shield&issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2F4ver%2Fnimate?ref=badge_shield&issueType=license) | ||
[![codecov](https://codecov.io/gh/4ver/nimate/branch/main/graph/badge.svg)](https://codecov.io/gh/4ver/nimate) | ||
@@ -9,7 +11,11 @@ **nimate** is a simple, flexible animation library designed to work across all JavaScript environments. With **nimate**, you can create smooth animations and sequence them with ease, utilizing easing functions from the `ts-easing` package. | ||
- Supports animations of numbers, objects, and arrays. | ||
- [streamich/ts-easing](https://github.com/streamich/ts-easing) for easing. | ||
- Configurable sequences that can run in parallel or series. | ||
- Works in browsers, Node.js, and other JavaScript environments. | ||
- Emits events for `start`, `update`, `complete`, and `stop` for animations and sequences. | ||
- **Flexible Animation Support**: Animate numbers, objects, and arrays with ease. | ||
- **Easing Functions**: Uses [streamich/ts-easing](https://github.com/streamich/ts-easing) for a variety of easing functions. | ||
- **Cross-Environment Compatibility**: Works seamlessly in browsers, Node.js, and other JavaScript environments. | ||
- **Events**: Emits events for `start`, `update`, `complete`, and `stop` for animations, sequences, blends, and queues. | ||
- **Promise Support**: Supports promises to allow for easy synchronization and chaining. | ||
- **Blended Animations**: Combine multiple animations into a single blended animation using custom blend functions. | ||
- **Queues**: Queue support so animations added to the queue auto-run on a fifo basis. | ||
- **Sequences**: Create sequences of animations that can run either in parallel or in series. | ||
- **Flexible Configuration**: Update animation properties on the fly with the `set` method. | ||
@@ -29,3 +35,3 @@ ## 📦 Installation | ||
```javascript | ||
import { Animate, Easing } from 'nimate'; | ||
import { Animate, easing } from 'nimate'; | ||
@@ -37,3 +43,3 @@ // Create an animation | ||
duration: 1000, | ||
easing: Easing.easeInOutQuad, | ||
easing: easing.easeInOutQuad, | ||
}); | ||
@@ -52,3 +58,3 @@ | ||
```javascript | ||
import { Animate, Sequence, Easing } from 'nimate'; | ||
import { Animate, Sequence, easing } from 'nimate'; | ||
@@ -60,3 +66,3 @@ // Create individual animations | ||
duration: 1000, | ||
easing: Easing.easeInOutQuad, | ||
easing: easing.easeInOutQuad, | ||
}); | ||
@@ -68,3 +74,3 @@ | ||
duration: 1000, | ||
easing: Easing.easeInOutQuad, | ||
easing: easing.easeInOutQuad, | ||
}); | ||
@@ -87,3 +93,3 @@ | ||
```javascript | ||
import { Animate, Sequence, Easing } from 'nimate'; | ||
import { Animate, Sequence, easing } from 'nimate'; | ||
@@ -95,3 +101,3 @@ // Create individual animations | ||
duration: 1000, | ||
easing: Easing.easeInOutQuad, | ||
easing: easing.easeInOutQuad, | ||
}); | ||
@@ -103,3 +109,3 @@ | ||
duration: 1000, | ||
easing: Easing.easeInOutQuad, | ||
easing: easing.easeInOutQuad, | ||
}); | ||
@@ -111,3 +117,3 @@ | ||
duration: 1000, | ||
easing: Easing.easeInOutQuad, | ||
easing: easing.easeInOutQuad, | ||
}); | ||
@@ -135,3 +141,3 @@ | ||
```javascript | ||
import { Animate, Queue, Easing } from 'nimate'; | ||
import { Animate, Queue, easing } from 'nimate'; | ||
@@ -143,3 +149,3 @@ // Create individual animations | ||
duration: 1000, | ||
easing: Easing.easeInOutQuad, | ||
easing: easing.easeInOutQuad, | ||
}); | ||
@@ -151,3 +157,3 @@ | ||
duration: 1000, | ||
easing: Easing.easeInOutQuad, | ||
easing: easing.easeInOutQuad, | ||
}); | ||
@@ -208,3 +214,3 @@ | ||
// Start the blend animation | ||
blend.start(); | ||
blend.start() | ||
``` | ||
@@ -223,3 +229,3 @@ | ||
- `duration` (number): The duration of the animation in milliseconds. | ||
- `easing` (EasingFunction, optional): The easing function to use. Default is `Easing.linear`. | ||
- `easing` (EasingFunction, optional): The easing function to use. Default is `easing.linear`. | ||
- `delay` (number, optional): The delay before the animation starts in milliseconds. Default is `0`. | ||
@@ -231,5 +237,6 @@ - `direction` ('normal' | 'reverse' | 'alternate', optional): The direction of the animation. Default is `'normal'`. | ||
- `start()`: Starts the animation. | ||
- `stop()`: Stops the animation. | ||
- `start()`: Starts the animation and returns the animation instance. | ||
- `stop()`: Stops the animation and returns the animation instance. | ||
- `set(options: SetOptions)`: Updates the animation properties while it is running. | ||
- `promise()`: Returns a promise that resolves when the animation completes. | ||
@@ -266,4 +273,5 @@ #### Events | ||
- `start()`: Starts the sequence. | ||
- `stop()`: Stops the sequence. | ||
- `start()`: Starts the sequence and returns the sequence instance. | ||
- `stop()`: Stops the sequence and returns the sequence instance. | ||
- `promise()`: Returns a promise that resolves when the sequence completes. | ||
@@ -279,11 +287,10 @@ #### Events | ||
Creates a queue of animations that are executed sequentially. | ||
`Animate` objects in the queue are called sequentially and removed when complete. The start function of each `Animate` is called automatically when it is next to be played. For example, if the queue is empty and an `Animate` is added, it is played immediately." | ||
#### Methods | ||
- `add(animation | ||
: Animate | Blend)`: Adds an `Animate` or `Blend` instance to the queue. | ||
- `add(animation: Animate | Blend)`: Adds an `Animate` or `Blend` instance to the queue. | ||
- `clear()`: Clears the queue and stops any currently running animation. | ||
- `stop()`: Stops the currently running animation without clearing the queue. | ||
- `promise()`: Returns a promise that resolves when all animations in the queue are complete. | ||
@@ -309,5 +316,6 @@ #### Events | ||
- `start()`: Starts the blended animation. | ||
- `stop()`: Stops the blended animation. | ||
- `start()`: Starts the blended animation and returns the blend instance. | ||
- `stop()`: Stops the blended animation and returns the blend instance. | ||
- `setBlendFunction(blendFunction: BlendFunction)`: Sets a new blend function. | ||
- `promise()`: Returns a promise that resolves when the blended animation completes. | ||
@@ -320,1 +328,5 @@ #### Events | ||
- `stop`: Emitted when the blended animation is stopped. | ||
## License | ||
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2F4ver%2Fnimate.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2F4ver%2Fnimate?ref=badge_large) |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
35190
613
312
2