2.4.7 • Published 2 years ago

lesca-object-tweener v2.4.7

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

React React React React React NPM React NPM

Why use it?

tween object value.

Live Demo

Installation

npm install lesca-object-tweener --save

Usage

import Tweener, { Bezier } from 'lesca-object-tweener';

// use single tween
const tweener = new Tweener({
  from: { top: 0, left: 0 },
  to: { top: 500, left: 500 },
  duration: 1000,
  delay: 1000,
  easing: Bezier.linear,
  onUpdate: (e) => console.log(e), // {top:0~500, left:0~500}
  onComplete: (e) => console.log(e), // { top: 500, left: 500 }
}).play();

tweener
  .add({
    to: { top: 1000 },
    duration: 1000,
    delay: 1000,
    easing: Bezier.easeInOutQuint,
    onStart: () => alert('start'),
    onUpdate: (e) => console.log(e), // {top:0~1000, left:500}
    onComplete: (e) => console.log(e), // {top:1000, left:500}
  })
  .play();
// use multiple tween
const tweener = new Tweener();

[
  { top: 0, left: 0 },
  { top: 100, left: 100 },
].forEach((data) => {
  tweener.add({
    from: { top: 0 }, // first loop will add "from". Second time tweener will ignore "from"
    to: { top: 100 },
    duration: 0,
    easing: Bezier.easeInOutQuint,
    onUpdate: (e) => console.log(e), // { top:0~100 }
    onComplete: (e) => console.log(e), // { top:100 }
  });
});
tweener.play(); // Need to run play when new constructor without any params

Development

Methods

Methodsoptionsdescriptiondefault
new Tweener( params:object )paramsnew Tweener class
.add(params:object)paramstween object
.stop()stop tween

Properties

Propertiestypedescriptiondefault
params.fromobjectobject value = number
params.toobjectobject value = number
params.durationnumbertween duration1000
params.delaynumbertween delay0
params.easingarraycubic-bezier 4 valueseaseOutQuart
params.onUpdatefunctioncall by framevoid
params.onCompletefunctioncall when endvoid
params.onStartfunctioncall when startvoid

Features

  • maintain if necessary

references

css-cubic-bezier-generator

bezier-easing

2.4.7

2 years ago

2.4.6

2 years ago

2.4.5

2 years ago

2.4.0

3 years ago

2.4.3

3 years ago

2.3.4

3 years ago

2.4.2

3 years ago

2.4.4

3 years ago

2.3.2

3 years ago

2.3.3

3 years ago

2.3.0

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.2.3

3 years ago

2.3.1

3 years ago

2.2.2

3 years ago

2.2.4

3 years ago

2.1.0

4 years ago

2.0.5

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.8

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.4

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago