IntervalController

A IntervalController tracks a single value (frame) and increments it once every delay seconds. The interval may be paused and resumed with the start and stop methods.

OptionTypeDefaultValueDescription
onChangefunction() => nullOptional - A callback to run when the controller completes an interval.
delaynumber1Optional - The amount of time in seconds to wait between intervals.
pausedbooleanfalseOptional - Whether the controller should start paused.
cleanResumebooleanfalseOptional - Whether the controller should begin from a new interval when resuming from paused.
PropertyTypeDescription
framenumberThe controller's current frame.
delaynumberThe controller's delay between intervals.
pausedbooleanWhether the controller is paused.
MethodDescription
start()Start the controller's interval, if paused.
stop()Stop the controller's interval, if paused.
toggle()Start the controller if paused, or else stop the controller.

Example: