voxolith

prepareSurface()

Make an element behave as an input surface on touch devices: no browser panning or pinch-zooming over it, no text selection, no tap flash, and (optionally) no context menu, so right-drag can be a gesture. Use this instead of per-app touch-action CSS. DOM-only.

function prepareSurface(el: HTMLElement, opts?: object): () => void;

Defined in: engine/src/input/core.ts:539

Parameters

ParameterTypeDescription
elHTMLElement-
opts?{ contextMenu?: boolean; }contextMenu: false suppresses the context menu over the element.
opts.contextMenu?boolean-

Returns

A function that restores the previous styles and removes the listener.

() => void

Example

prepareSurface(canvas, { contextMenu: false });
const input = createInput(canvas);

On this page