Class clock
Extends
component.
clock
Defined in: clock.js.
Constructor Attributes | Constructor Name and Description |
---|---|
clock()
An component that keeps track of time with millisecond resolution.
|
Field Attributes | Field Name and Description |
---|---|
Returns duration of the timer in milliseconds.
|
|
Returns whether the clock as expired.
|
|
Returns whether the clock is in a paused state.
|
|
Returns the number of milliseconds left until the clock expires
|
|
Returns the number of milliseconds since the clock was last set.
|
- Fields borrowed from class component:
- host, info, isDrawing, isStepping, onAttach, onDraw, onStep, tag
Method Attributes | Method Name and Description |
---|---|
pause()
Pauses the timer.
|
|
reset()
Resets the timer with the time it had previously
|
|
resume()
Resumes the timer from the pause state.
|
|
set(time)
Resets the timer with the time it should expire in milliseconds.
|
- Methods borrowed from class component:
- canHandleEvent, draw, emitEvent, getKnownEvents, installEvent, installHandler, installHook, step, uninstallEvent, uninstallHandler, uninstallHook
Class Detail
clock()
An component that keeps track of time with millisecond resolution. Instantiates with sandboxe.clock.create()
Grants functionality similar to using a stopwatch. Note that all properties
are readonly. Writing to them will have no effect and will not persist.
Known component events:
- clock-step: Called every step when the clock is active. - clock-draw: Called every draw when the clock is active. - clock-expire: Called when the clock expires
Field Detail
duration
Returns duration of the timer in milliseconds.
expired
Returns whether the clock as expired.
paused
Returns whether the clock is in a paused state.
timeLeft
Returns the number of milliseconds left until the clock expires
timeSince
Returns the number of milliseconds since the clock was last set.
Method Detail
pause()
Pauses the timer.
reset()
Resets the timer with the time it had previously
resume()
Resumes the timer from the pause state.
set(time)
Resets the timer with the time it should expire in milliseconds.
- Parameters:
- {Number} time
- If specified, sets the new duration for the timer. If excluded, the timer has no time limit.