1.2.2 • Published 5 years ago
timer-tracks v1.2.2
timer-tracks
Timeline's controller with label to navigate
Install
npm i timer-tracks
oryarn add timer-tracks
Importing
import TimerTracks from "timer-tracks";
Quick start
Usage timer-tracks plugin.
const tracks = [
{ name: "intro", duration: 5 },
{ name: "start", duration: 10 },
{ name: "end", duration: 5 },
{ name: "outro", duration: 20 }
];
const timerTracks = TimerTracks(tracks);
timerTracks.update(0);
timerTracks.current.name; //? intro
timerTracks.current.progress; //? 0
timerTracks.update(10);
timerTracks.current.name; //? start
timerTracks.current.progress; //? .5
Methods
.update(num)
Set progress current track and update current
attribute.
argument | type | Description |
---|---|---|
num | number | current progresse |
timerTracks.update(0);
timerTracks.update(10);
timerTracks.current.name; //? start
timerTracks.current.progress; //? .5
.goTo(name)
Set current track with name. And launch update()
to apply
argument | type | Description |
---|---|---|
name | string | name's target on tracks |
timerTracks.goto("end");
timerTracks.update(10);
timerTracks.current.name; //? end
timerTracks.current.progress; //? 0
.next()
Set current track with the next. And launch update()
to apply
the limit is null
timerTracks.next();
timerTracks.update(0);
.prev()
Set current track with the prev. And launch update()
to apply
the limit is the first tracks
timerTracks.prev();
timerTracks.update(0);