From bfc1d182be865ed1d371f2f49f5bd1f0ec830ce4 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sun, 1 Mar 2026 11:12:34 +0100 Subject: [PATCH] patchbay: interaction and rendering issues + use draginit instead of fast-click --- CHANGELOG.md | 1 + src/client/widgets/containers/patchbay.mjs | 35 ++++++++++++++-------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd017e0e..4f279bd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - bug fixes - when using objects in properties, numbers-as-strings and booleans-as-strings values are now preserved instead of being converted to their litteral counterparts - rgb: fix rendering issue + - patchbay: interaction and rendering issues - editor - preserve code editor undo history between consecutive edits of a same widget's property diff --git a/src/client/widgets/containers/patchbay.mjs b/src/client/widgets/containers/patchbay.mjs index 931bac01..ceaf03db 100644 --- a/src/client/widgets/containers/patchbay.mjs +++ b/src/client/widgets/containers/patchbay.mjs @@ -200,31 +200,42 @@ class PatchBay extends Container(Canvas) { this.connecting = [] + this.mousePosition = [] + this.dragging = false - this.on('fast-click', (e)=>{ + this.on('draginit', (e)=>{ this.toggleConnection(e.target) - e.stopPropagation() + if (e.target === this.canvas) { + this.mousePosition = [e.offsetX, e.offsetY] + } else { + if (this.inputNodes.includes(e.target)) { + this.mousePosition = [e.offsetX - e.target.offsetWidth, e.offsetY + e.target.offsetTop] + } else { + this.mousePosition = [e.offsetX + this.canvas.offsetWidth, e.offsetY + e.target.offsetTop] + } + } }, {element: this.widget}) - - this.mousePosition = [] this.on('drag', (e)=>{ if (!this.connecting.length) { this.toggleConnection(e.target) } - if (e.target === this.canvas) { - this.mousePosition = [e.offsetX, e.offsetY] - } else if (this.mousePosition.length) { - this.mousePosition[0] += e.movementX - this.mousePosition[1] += e.movementY - } + this.mousePosition[0] += e.movementX + this.mousePosition[1] += e.movementY + this.dragging = true this.batchDraw() }, {element: this.widget}) + this.on('dragend', (e)=>{ - if (this.mousePosition.length) { + + if (this.dragging) { + // touch hover fix + var node = e.isTouch ? document.elementFromPoint(e.clientX, e.clientY) : e.target + this.mousePosition = [] - this.toggleConnection(e.target) + this.toggleConnection(node) } + this.dragging = false }, {element: this.widget})