Skip to content

Handler

Defined in: ui/handler_manager.ts:59

Handlers interpret dom events and return camera changes that should be applied to the map (HandlerResults). The camera changes are all deltas. The handler itself should have no knowledge of the map's current state. This makes it easier to merge multiple results and keeps handlers simpler. For example, if there is a mousedown and mousemove, the mousePan handler would return a panDelta on the mousemove.

Methods

isActive()

isActive(): boolean

Defined in: ui/handler_manager.ts:68

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


isZooming()?

optional isZooming(): boolean

Defined in: ui/handler_manager.ts:99

Whether the handler is zooming the map apart from the zoom deltas it returns, such as a wheel zoom between a wheel event and its first frame.

Returns

boolean


onTimeout()?

optional onTimeout(token: unknown): void | HandlerResult

Defined in: ui/handler_manager.ts:105

Called by the manager when a timeout the handler asked for runs out, see HandlerResult.timeout. The manager runs a render frame when the result asks for one. The token is opaque to the manager, so a handler declares the parameter as the type of the tokens it hands out.

Parameters

Parameter Type
token unknown

Returns

void | HandlerResult


reset()

reset(): void

Defined in: ui/handler_manager.ts:72

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

Returns

void

Properties

renderFrame?

readonly optional renderFrame?: () => void | HandlerResult

Defined in: ui/handler_manager.ts:94

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

void | HandlerResult