Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Timer

Count-up or count-down timer. Can optionally update an html element.

Hierarchy

  • Timer

Index

Constructors

constructor

  • new Timer(htmlElement?: HTMLElement): Timer
  • Parameters

    • Optional htmlElement: HTMLElement

    Returns Timer

Properties

count_down

count_down: boolean

Optional end_callback

end_callback: undefined | function

Optional end_value

end_value: undefined | number

Optional html_element

html_element: HTMLElement

Optional interval_f

interval_f: undefined | number

is_active

is_active: boolean

start_value

start_value: number

Optional tick_callback

tick_callback: undefined | function

time_count

time_count: number

Methods

add

  • add(time: number): void
  • Adds time to the current value in the timer. So for example, if the timer is right now at 4 seconds, and we add 1000 (1 second), it jumps to 5 seconds.

    Parameters

    • time: number

      In milliseconds.

    Returns void

getTimeMilliseconds

  • getTimeMilliseconds(): number
  • Returns the time it has passed so far, in milliseconds.

    Returns number

getTimeSeconds

  • getTimeSeconds(): number
  • Returns the time it has passed so far, in seconds.

    Returns number

getTimeString

  • getTimeString(): string
  • Returns a string with the time passed so far.

    Returns string

reset

  • reset(): void
  • Stops and resets the count.

    Returns void

restart

  • restart(): void
  • Restart the timer.

    Returns void

resume

  • resume(): void
  • Resumes the timer with the same settings/values that were set before it was stopped.

    Returns void

start

  • start(args?: undefined | object): void
  • Start counting. If no endValue is given, it never stops counting.

    startValue and endValue are in milliseconds.

    endCallback is called when the timer ends (only if an endValue was provided).

    tickCallback is called every second.

    Parameters

    • Optional args: undefined | object

    Returns void

stop

  • stop(): void
  • Stop counting.

    Returns void

updateHtmlElement

  • updateHtmlElement(): void
  • Updates the associated html element (if was given) with the current time value.

    Returns void

Generated using TypeDoc