# Class: AnimationTimer

## AnimationTimer(callback)

#### new AnimationTimer(callback)

Animation timer should be used to run the update and render loops of the application. Underneat it uses the requestAnimationFrame() method that calls the function with the same rate as the screen refresh rate.

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | function | Timer callback function.

Source:
  - utils/AnimationTimer.js, line 9

### Members

#### callback :function

Task of the timer, executed at the timer defined rate.

##### Type:

- function

Source:
  - utils/AnimationTimer.js, line 16

#### id :number

ID of the currently waiting timeout clock. Used to cancel the already request execution of the next clock tick.

##### Type:

- number

Source:
  - utils/AnimationTimer.js, line 30

#### running :boolean

Indicates if the timer is currently running, it is set to true on start and reset to false on stop.

##### Type:

- boolean

Source:
  - utils/AnimationTimer.js, line 23

### Methods

#### start()

Start timer, is the timer is already running does not do anything.

Source:
  - utils/AnimationTimer.js, line 36

#### stop()

Stop animation timer, should be called when the render loop is no longer in use to prevent code/memory leaks. If the timer is not stopped the loop will keep running using processing power and consuming memory.

Source:
  - utils/AnimationTimer.js, line 64