Comparing version 1.1.2 to 1.2.0
@@ -47,6 +47,3 @@ "use strict"; | ||
const currentValue = this.getInterpolatedValue(this.from, this.to, easedT); | ||
if (JSON.stringify(currentValue) !== JSON.stringify(this.previousValue)) { | ||
this.emit('update', currentValue); | ||
this.previousValue = currentValue; | ||
} | ||
this.emit('update', currentValue); | ||
// Check if animation is complete | ||
@@ -53,0 +50,0 @@ if ((!this.isReversed && t < 1) || (this.isReversed && t > 0)) { |
{ | ||
"name": "nimate", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "A simple, flexible animation library.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -122,2 +122,36 @@ # nimate | ||
### Queue of Animations | ||
```javascript | ||
import { Animate, Queue, Easing } from 'nimate'; | ||
// Create individual animations | ||
const animate1 = new Animate({ | ||
from: { x: 0, y: 0 }, | ||
to: { x: 100, y: 50 }, | ||
duration: 1000, | ||
easing: Easing.easeInOutQuad, | ||
}); | ||
const animate2 = new Animate({ | ||
from: { x: 100, y: 50 }, | ||
to: { x: 200, y: 100 }, | ||
duration: 1000, | ||
easing: Easing.easeInOutQuad, | ||
}); | ||
// Create a queue and add animations | ||
const queue = new Queue(); | ||
queue.add(animate1); | ||
queue.add(animate2); | ||
// Attach event listeners | ||
queue | ||
.on('start', (animation) => console.log('Queue Animation Start', animation)) | ||
.on('update', (value, animation) => console.log('Queue Animation Update:', value, animation)) | ||
.on('complete', (animation) => console.log('Queue Animation Complete', animation)) | ||
.on('stop', (animation) => console.log('Queue Animation Stop', animation)) | ||
.on('complete', () => console.log('All animations in the queue are complete')); | ||
``` | ||
## 📚 API | ||
@@ -171,1 +205,20 @@ | ||
- `stop`: Emitted when the sequence is stopped. | ||
### `Queue` | ||
Creates a queue of animations that are executed sequentially. | ||
#### Methods | ||
- `add(animation: Animate)`: Adds an `Animate` instance to the queue. | ||
- `clear()`: Clears the queue and stops any currently running animation. | ||
- `stop()`: Stops the currently running animation without clearing the queue. | ||
#### Events | ||
- `start`: Emitted when an animation in the queue starts. | ||
- `update`: Emitted on each update with the current value and animation. | ||
- `complete`: Emitted when an animation in the queue completes. | ||
- `stop`: Emitted when an animation in the queue is stopped. | ||
- `complete`: Emitted when all animations in the queue are complete. | ||
``` |
22380
13
367
223