# Class: ViewportControls

## ViewportControls(viewport)

#### new ViewportControls(viewport)

Viewport controls are used to allow the user to control the viewport. The user controls the viewport using pointer input (e.g. mouse, touchscreen)

##### Parameters:

Name | Type | Description
--- | --- | ---
`viewport` | Viewport |

Source:
  - controls/ViewportControls.js, line 13

### Members

#### (static) RECENTER_CANVAS :number

Recenter the viewport automatically to the canvas. This will ensure that rotation and scaling will not cause the viewport to move around.

##### Type:

- number

Source:
  - controls/ViewportControls.js, line 102

#### (static) RECENTER_NONE :number

Viewport is not automatically recentered. The center point can be set manually by the developer.

##### Type:

- number

Source:
  - controls/ViewportControls.js, line 93

#### (static) RECENTER_POINTER :number

Viewport should automatically cente ron the pointer position. The viewport will simulataniously move to the pointer position while scalling. For some application its easier to focus the target if the viewport moves to the pointer location while scalling.

##### Type:

- number

Source:
  - controls/ViewportControls.js, line 113

#### allowRotation :boolean

If true allows the viewport to be rotated. Rotation is performed by holding the RIGHT and LEFT pointer buttons and rotating around the initial point.

##### Type:

- boolean

Source:
  - controls/ViewportControls.js, line 63

#### allowScale :boolean

Is set to true allow the viewport to be scalled. Scaling is performed using the pointer scroll.

##### Type:

- boolean

Source:
  - controls/ViewportControls.js, line 45

#### dragButton :number

Button used to drag and viewport around. On touch enabled devices the touch event is represented as a LEFT button.

##### Type:

- number

Source:
  - controls/ViewportControls.js, line 29

#### recenterViewport :number

Flag to indicate if the viewport should automatically be recentered. This will cause the viewport center property to be automatically set based on an heuristic defined by the user.

##### Type:

- number

Source:
  - controls/ViewportControls.js, line 54

#### rotateButton :number

Button used to rotate the viewport.

##### Type:

- number

Source:
  - controls/ViewportControls.js, line 36

#### rotationInitial :number

Initial rotation of the viewport. Is set to the current rotation of the viewport when the rotation starts.

##### Type:

- number

Source:
  - controls/ViewportControls.js, line 83

#### rotationPoint :Vector2|null

Value of the initial point of rotation if the viewport is being rotated. Is the value of the pointer position when the rotation starts. Is set to null when the viewport is not being rotated.

##### Type:

- Vector2 | null

Source:
  - controls/ViewportControls.js, line 74

#### viewport :Viewport

Viewport being controlled by this object.

##### Type:

- Viewport

Source:
  - controls/ViewportControls.js, line 20

### Methods

#### update(pointer)

Update the viewport controls using the pointer object. Should be called every frame before rendering.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pointer` | Pointer | Pointer used to control the viewport.

Source:
  - controls/ViewportControls.js, line 122