simple-inertia
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

sample-inertia

一个简单的惯性库

Usage

import Inertia from 'sample-inertia';

const inertia = new Inertia();

let times = 0
let distance = 0

// 开始主动滑动物体
const timer = setInterval(() => {
    distance += 20;
    times += 1;

    inertia.move(distance);

    if (times >= 100) {
        clearInterval(timer);
        slide();
    }
}, 1000 / 60);

// 依靠惯性继续滑动
function slide() {
    inertia.loose(({ value, diff }) => {
        console.log(value, diff);
    })
}

Readme

Keywords

none

Package Sidebar

Install

npm i simple-inertia

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

28.1 kB

Total Files

22

Last publish

Collaborators

  • pspgbhu