patchbay: interaction and rendering issues + use draginit instead of fast-click
This commit is contained in:
parent
e682455872
commit
bfc1d182be
2 changed files with 24 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue