Skip to content

@fabwcie/free-drawing / utils/SpacePan

utils/SpacePan ​

Classes ​

SpacePan ​

Defined in: packages/free-drawing/src/utils/SpacePan.ts:10

Hand of the Space key: while Space is held (focus on the drawing, or pointer on the canvas out of the fields of the drawer), a drag moves the view whatever the tool, as the pan tool; the tool and the selection stay as they were. Shapes and the transformer are not reached meanwhile (layers not listening), tools ignore the pointer (active). A drag with the middle button of the mouse moves the view too (tools ignore this button)

Constructors ​

Constructor ​

new SpacePan(drawer): SpacePan

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

Released with Space, or once the page loses focus (Space released out of it)

Parameters
drawer ​

Drawer

Drawer whose view is moved

Returns

SpacePan

Properties ​

active ​

active: boolean = false

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

Space held: a drag moves the view, tools ignore the pointer

drawer ​

drawer: Drawer

Defined in: packages/free-drawing/src/utils/SpacePan.ts:12

Drawer whose view is moved

Methods ​

_initMiddleButton() ​

private _initMiddleButton(): void

Defined in: packages/free-drawing/src/utils/SpacePan.ts:48

Middle button dragged on the canvas: the view follows it whatever the tool (no autoscroll of the browser), change fired once released when it moved (view saved)

Returns

void

_toolChanged() ​

_toolChanged(): void

Defined in: packages/free-drawing/src/utils/SpacePan.ts:145

Tool changed while Space is held (button of the toolbar clicked): drags still move the view until Space is released

Returns

void

handleKey() ​

handleKey(e): boolean

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

Keydown of the drawer (HotKey): Space starts the hand, its repeats are kept from the page

Parameters
e ​

KeyboardEvent

Keydown of the drawer

Returns

boolean

true when the key was used (its default prevented by HotKey)

start() ​

start(): void

Defined in: packages/free-drawing/src/utils/SpacePan.ts:123

Drags move the view: stage draggable, shapes and transformer out of reach, grab cursor

Returns

void

stop() ​

stop(): void

Defined in: packages/free-drawing/src/utils/SpacePan.ts:155

Back to the tool: drag stopped, stage draggable with the pan tool only (the tool may have changed meanwhile), layers as before, cursor of the tool, change fired when the view moved (view saved)

Returns

void