From 9b229220a32c811ad67643fcaaabb3dede53935f Mon Sep 17 00:00:00 2001 From: bymyself Date: Tue, 6 Aug 2024 10:36:08 -0700 Subject: [PATCH] centerOnNode use DPI (#49) --- src/litegraph.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/litegraph.js b/src/litegraph.js index 6286753bb..fc917c11a 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -7616,14 +7616,15 @@ LGraphNode.prototype.executeAction = function(action) * @method centerOnNode **/ LGraphCanvas.prototype.centerOnNode = function(node) { + const dpi = window?.devicePixelRatio || 1; this.ds.offset[0] = -node.pos[0] - node.size[0] * 0.5 + - (this.canvas.width * 0.5) / this.ds.scale; + (this.canvas.width * 0.5) / (this.ds.scale * dpi); this.ds.offset[1] = -node.pos[1] - node.size[1] * 0.5 + - (this.canvas.height * 0.5) / this.ds.scale; + (this.canvas.height * 0.5) / (this.ds.scale * dpi); this.setDirty(true, true); };