Why use it?
Use it calculator timestamp for animation.
Live Demo
Installation
npm install lesca-enterframe --saveUsage
As a Node module:
import { useState, useEffect } from 'react';
import EnterFrame from 'lesca-enterframe';
const Component = () => {
const [time, setTime] = useState(0);
useEffect(() => {
EnterFrame.add((e) => {
const { delta } = e;
setTime(delta);
});
}, []);
return (
<div>
<h1>{time}</h1>
<button onClick={() => EnterFrame.play()}>Play</button>
<button onClick={() => EnterFrame.stop()}>Stop</button>
</div>
);
};Development
Methods
| method | description | return |
|---|---|---|
| .add(frame:function) | extend call func | void |
| .play() | continue calling func | void |
| .stop() | stop calling func | void |
| .undo() | reverse to last function | void |
| .destroy() | remove event | void |
| .setFPS(fps:number) | set FPS | void |
| .reset(fps:number) | reset delta | void |
Properties
| Properties | type | description | default |
|---|---|---|---|
| todo | Object | get function and list of function history | [] |
Features
- maintain if necessary