count-slowly
Usage
const countSlowly = ; const cs = ; // Set the initial valuecs;// Handle values between your final valuecs; // Update value when neededcs; // Skip directly to the new value. Calls onUpdate callback with final value then stops.cs; // Stops the onUpdate callbacks without skipping to new value.cs;
factory function
Rely on the .update() method to determine the values.
const cs = ;
Set the starting value straight-away.
const cs = ;
Set a default duration to stay on each step
const cs = ;
Set the default length of time to arrive at the new count
const cs = ;
.set()
Set an initial integer value. This will call the .onUpdate() callback once if it has been set.
cs;
.onUpdate()
Set the callback from each integer between the old value and the new value.
cs;
.update()
Set a new value. This will call the .onUpdate() callback for each integer between the old integer and the new integer according to either the factory function's stepDuration
or totalDuration
value.
cs;
Set a new value, calling the .onUpdate() callback every 50ms regardless of the factory function's stepDuration
or totalDuration
value.
cs;
Set a new value, calling the .onUpdate() callback as often as needed in order to invoke the callback with 100
after 1200ms regardless of the factory function's stepDuration
or totalDuration
value.
cs;
.hurry()
Skip directly to the new value. Calls the .onUpdate() callback with final value then stops.
cs;
.stop()
Stop the .onUpdate() callbacks without skipping to the new value.
cs;