Skip to content

ScrollZoomHandler

The ScrollZoomHandler allows the user to zoom the map by scrolling.

Implements

Methods

disable()

disable(): void

Disables the "scroll to zoom" interaction.

Returns

void

Implementation of

Handler.disable

Example

map.scrollZoom.disable();

Defined in

src/ui/handler/scroll_zoom.ts:147


enable()

enable(options?: boolean | AroundCenterOptions): void

Enables the "scroll to zoom" interaction.

Parameters

Parameter Type Description
options? boolean | AroundCenterOptions Options object.

Returns

void

Implementation of

Handler.enable

Example

map.scrollZoom.enable();
map.scrollZoom.enable({ around: 'center' })

Defined in

src/ui/handler/scroll_zoom.ts:133


isActive()

isActive(): boolean

This is used to indicate if the handler is currently active or not. In case a handler is active, it will block other handlers from getting the relevant events. There is an allow list of handlers that can be active at the same time, which is configured when adding a handler.

Returns

boolean

Implementation of

Handler.isActive

Defined in

src/ui/handler/scroll_zoom.ts:115


isEnabled()

isEnabled(): boolean

Returns a Boolean indicating whether the "scroll to zoom" interaction is enabled.

Returns

boolean

true if the "scroll to zoom" interaction is enabled.

Implementation of

Handler.isEnabled

Defined in

src/ui/handler/scroll_zoom.ts:106


renderFrame()

renderFrame(): object

renderFrame is the only non-dom event. It is called during render frames and can be used to smooth camera changes (see scroll handler).

Returns

object

around

around: Point

needsRenderFrame

needsRenderFrame: boolean = !finished

noInertia

noInertia: boolean = true

originalEvent

originalEvent: any

zoomDelta

zoomDelta: number

Implementation of

Handler.renderFrame

Defined in

src/ui/handler/scroll_zoom.ts:251


reset()

reset(): void

reset can be called by the manager at any time and must reset everything to it's original state

Returns

void

Implementation of

Handler.reset

Defined in

src/ui/handler/scroll_zoom.ts:353


setWheelZoomRate()

setWheelZoomRate(wheelZoomRate: number): void

Set the zoom rate of a mouse wheel

Parameters

Parameter Type Description
wheelZoomRate number 1/450 The rate used to scale mouse wheel movement to a zoom value.

Returns

void

Example

Slow down zoom of mouse wheel

map.scrollZoom.setWheelZoomRate(1/600);

Defined in

src/ui/handler/scroll_zoom.ts:98


setZoomRate()

setZoomRate(zoomRate: number): void

Set the zoom rate of a trackpad

Parameters

Parameter Type Description
zoomRate number 1/100 The rate used to scale trackpad movement to a zoom value.

Returns

void

Example

Speed up trackpad zoom

map.scrollZoom.setZoomRate(1/25);

Defined in

src/ui/handler/scroll_zoom.ts:85