Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sfi0zy/weeee

Tiny Javascript tweening engine.
https://github.com/sfi0zy/weeee

animation tween

Last synced: 3 months ago
JSON representation

Tiny Javascript tweening engine.

Awesome Lists containing this project

README

        

# Weeee.js
![](https://img.shields.io/badge/version-1.0.3-brightgreen) ![](https://img.shields.io/badge/dependencies-0-brightgreen) ![](https://img.shields.io/badge/license-MIT-brightgreen)

Tiny Javascript tweening engine.

[Homepage](https://sfi0zy.github.io/weeee)

![Weeee.js](main.png)

## Usage

Step 1:

```sh
npm install --save weeee.js
```

Step 2:

```javascript
import Weeee from 'weeee.js';

const example = new Weeee({
//

//

// Weeee.easeLinear
// Weeee.easeInCubic
// Weeee.easeOutCubic
// Weeee.easeInExpo
// Weeee.easeOutExpo
// Weeee.easeInElastic
// Weeee.easeOutElastic
//
easing: Weeee.easeLinear,

// Weeee.normal
// Weeee.reverse
// Weeee.alternate
direction: Weeee.normal,

// true
// false
autoplay: true,

// false
//
// Infinity
loop: false,

//

//
fps: 60,

//
//
// Weeee doesn't force us to manipulate with specific CSS, SVG,
// Canvas or WebGL objects. Just do whatever you want here.
//
// Progress will be from 0 to 1.
//
// Additional details include:
// - startTime (when animation has been started, in ms)
// - currentTime (current time, may bee needed in infinite animations, in ms)
// - delta (time from the start, "currentTime - startTime", in ms)
// - isFinished (becomes true in the last frame of the finite animation)
func: (progress, details) => {
myElement.style.transform = `scale(${progress})`;
},

// Optional callback. It will be executed after the last frame of the animation.
callback: () => {
console.log('weeee!');
}
});

// Also it's possible to start/stop/restart it manually. Callback will NOT be executed.
//
// example.start();
// example.stop();
// example.restart();
```

## CDN

It's possible to import Weeee right from the unpkg:

```javascript
import Weeee from 'https://unpkg.com/weeee.js/weeee.js';
```

## More examples

Examples on CodePen:

1. [Page loading](https://codepen.io/sfi0zy/pen/mdWQwzL)
2. [Spinner](https://codepen.io/sfi0zy/pen/bGqQMvN)

## License

MIT License

Copyright (c) 2021 Ivan Bogachev [email protected]