tldraw
Version:
A tiny little drawing editor.
46 lines (45 loc) • 1.47 kB
JavaScript
import { EASINGS, StateNode } from "@tldraw/editor";
import { Dragging } from "./childStates/Dragging.mjs";
import { Idle } from "./childStates/Idle.mjs";
import { Pointing } from "./childStates/Pointing.mjs";
class HandTool extends StateNode {
static id = "hand";
static initial = "idle";
static isLockable = false;
static children() {
return [Idle, Pointing, Dragging];
}
onDoubleClick(info) {
if (info.phase === "settle") {
const currentScreenPoint = this.editor.inputs.getCurrentScreenPoint();
this.editor.zoomIn(currentScreenPoint, {
animation: { duration: 220, easing: EASINGS.easeOutQuint }
});
}
}
onTripleClick(info) {
if (info.phase === "settle") {
const currentScreenPoint = this.editor.inputs.getCurrentScreenPoint();
this.editor.zoomOut(currentScreenPoint, {
animation: { duration: 320, easing: EASINGS.easeOutQuint }
});
}
}
onQuadrupleClick(info) {
if (info.phase === "settle") {
const zoomLevel = this.editor.getZoomLevel();
const currentScreenPoint = this.editor.inputs.getCurrentScreenPoint();
if (zoomLevel === 1) {
this.editor.zoomToFit({ animation: { duration: 400, easing: EASINGS.easeOutQuint } });
} else {
this.editor.resetZoom(currentScreenPoint, {
animation: { duration: 320, easing: EASINGS.easeOutQuint }
});
}
}
}
}
export {
HandTool
};
//# sourceMappingURL=HandTool.mjs.map