[Refactor] Update style (#473)

* Update #471 to use Point convention

* Prefer camel case var names
This commit is contained in:
filtered
2025-02-07 07:38:28 +11:00
committed by GitHub
parent 47e9abd4ea
commit c9f6b5ece8

View File

@@ -514,7 +514,7 @@ export class LGraphCanvas {
/** If true, enable drag zoom. Ctrl+Shift+Drag Up/Down: zoom canvas. */ /** If true, enable drag zoom. Ctrl+Shift+Drag Up/Down: zoom canvas. */
dragZoomEnabled: boolean = false dragZoomEnabled: boolean = false
/** The start position of the drag zoom. */ /** The start position of the drag zoom. */
#zoom_drag_start: { x: number, y: number, scale: number } | null = null #dragZoomStart: { pos: Point, scale: number } | null = null
getMenuOptions?(): IContextMenuValue[] getMenuOptions?(): IContextMenuValue[]
getExtraMenuOptions?( getExtraMenuOptions?(
@@ -1998,7 +1998,7 @@ export class LGraphCanvas {
processMouseDown(e: PointerEvent): void { processMouseDown(e: PointerEvent): void {
if (this.dragZoomEnabled && e.ctrlKey && e.shiftKey && !e.altKey && e.buttons) { if (this.dragZoomEnabled && e.ctrlKey && e.shiftKey && !e.altKey && e.buttons) {
this.#zoom_drag_start = { x: e.x, y: e.y, scale: this.ds.scale } this.#dragZoomStart = { pos: [e.x, e.y], scale: this.ds.scale }
return return
} }
@@ -2840,20 +2840,17 @@ export class LGraphCanvas {
#processDragZoom(e: PointerEvent): void { #processDragZoom(e: PointerEvent): void {
// stop canvas zoom action // stop canvas zoom action
if (!e.buttons) { if (!e.buttons) {
this.#zoom_drag_start = null this.#dragZoomStart = null
return return
} }
// calculate delta // calculate delta
const deltaY = e.y - this.#zoom_drag_start.y const deltaY = e.y - this.#dragZoomStart.pos[1]
const startScale = this.#zoom_drag_start.scale const startScale = this.#dragZoomStart.scale
const scale = startScale - deltaY / 100 const scale = startScale - deltaY / 100
this.ds.changeScale(scale, [ this.ds.changeScale(scale, this.#dragZoomStart.pos)
this.#zoom_drag_start.x,
this.#zoom_drag_start.y,
])
this.graph.change() this.graph.change()
} }
@@ -2861,7 +2858,7 @@ export class LGraphCanvas {
* Called when a mouse move event has to be processed * Called when a mouse move event has to be processed
*/ */
processMouseMove(e: PointerEvent): void { processMouseMove(e: PointerEvent): void {
if (this.dragZoomEnabled && e.ctrlKey && e.shiftKey && this.#zoom_drag_start) { if (this.dragZoomEnabled && e.ctrlKey && e.shiftKey && this.#dragZoomStart) {
this.#processDragZoom(e) this.#processDragZoom(e)
return return
} }