Skip to content

@fabwcie/free-drawing / utils/TouchGestures

utils/TouchGestures ​

Classes ​

TouchGestures ​

Defined in: packages/free-drawing/src/utils/TouchGestures.ts:14

Two finger gestures on the canvas of a drawer: pinching zooms around the fingers (zoom option), moving them moves the view (also in read only). Only fingers on the canvas count (targetTouches): a finger resting on the toolbar starts no gesture. The second finger cancels the pointer action of the first one (BaseWidget.cancelAction: shape or stroke being drawn removed, erasing, selecting or laser stopped, drags stopped); tools ignore touches until every finger is lifted (active). Listened after konva on its canvas: konva and the tools see each touch first.

Constructors ​

Constructor ​

new TouchGestures(drawer): TouchGestures

Defined in: packages/free-drawing/src/utils/TouchGestures.ts:26

Listen to touches of the canvas of the drawer (removed with it: signal)

Parameters
drawer ​

Drawer

Drawer whose view is zoomed and moved

Returns

TouchGestures

Properties ​

active ​

active: boolean = false

Defined in: packages/free-drawing/src/utils/TouchGestures.ts:16

Gesture in progress, until every finger is lifted: tools ignore touches meanwhile

drawer ​

private readonly drawer: Drawer

Defined in: packages/free-drawing/src/utils/TouchGestures.ts:20

Drawer whose view is moved

Methods ​

_onEnd() ​

private _onEnd(e): void

Defined in: packages/free-drawing/src/utils/TouchGestures.ts:90

Finger lifted: gesture followed from the fingers left, ended once every finger is lifted

Parameters
e ​

TouchEvent

Touch end or cancel on the canvas

Returns

void

_onMove() ​

private _onMove(e): void

Defined in: packages/free-drawing/src/utils/TouchGestures.ts:62

Fingers moved: zoom from their distance (zoom option), the point of the drawing under them stays under them

Parameters
e ​

TouchEvent

Touch move on the canvas

Returns

void

_onTouch() ​

private _onTouch(e): void

Defined in: packages/free-drawing/src/utils/TouchGestures.ts:43

Second finger: gesture started (action of the first finger cancelled), or followed from the fingers now on it

Parameters
e ​

TouchEvent

Touch start on the canvas

Returns

void

_read() ​

private _read(e): TouchGestureStart

Defined in: packages/free-drawing/src/utils/TouchGestures.ts:102

Two first fingers on the canvas and the view now

Parameters
e ​

TouchEvent

Touch event with two fingers on the canvas at least

Returns

TouchGestureStart

Distance and middle of the fingers in the canvas, zoom and position of the view