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

0.4.3 • Public • Published

Chaser

chaser

JavaScript variable chaser

Installation

npm install --save chaser

Usage

const chaser = require('chaser')
 
const myAnimatedVar = chaser(12) // 12 is our initial value here
myAnimateVar.target = 20
 
setInterval(() => {
    console.log(myAnimatedVar.value) // You can use .value anywhere and it will be generated accurately by timing function and passed time.
}, 10)

Chaser using React Hooks with useChaser

import { useChaser } from 'chaser'
 
function MovingBox() {
    const [posX, setPosX] = useChaser(0 /* initialValue */)
 
    return (
        <div style={{ transform: `translateX(${posX}px)` }}>
            <button onClick={() => setPosX(Math.random() * 100)} />
        </div>
    )
}

Example

If you're looking for an example, here's a unclean example! but works: https://alireza29675.github.io/chaser/

Contribute

Put issues! Suggest me what you need.

Readme

Keywords

none

Package Sidebar

Install

npm i chaser

Weekly Downloads

1

Version

0.4.3

License

MIT

Unpacked Size

14.7 kB

Total Files

16

Last publish

Collaborators

  • alireza29675