Skip to content

Commit 35e768d

Browse files
author
tamat
committed
fixed drag error
1 parent 49e3fe7 commit 35e768d

6 files changed

+1636
-1334
lines changed

build/litegraph.core.js

+40-12
Original file line numberDiff line numberDiff line change
@@ -2532,7 +2532,7 @@
25322532
var w = this.widgets[i];
25332533
if(!w)
25342534
continue;
2535-
if(w.options && w.options.property && this.properties[ w.options.property ])
2535+
if(w.options && w.options.property && (this.properties[ w.options.property ] != undefined))
25362536
w.value = JSON.parse( JSON.stringify( this.properties[ w.options.property ] ) );
25372537
}
25382538
if (info.widgets_values) {
@@ -3775,16 +3775,42 @@
37753775

37763776
/**
37773777
* returns the bounding of the object, used for rendering purposes
3778-
* bounding is: [topleft_cornerx, topleft_cornery, width, height]
37793778
* @method getBounding
3780-
* @return {Float32Array[4]} the total size
3779+
* @param out {Float32Array[4]?} [optional] a place to store the output, to free garbage
3780+
* @param compute_outer {boolean?} [optional] set to true to include the shadow and connection points in the bounding calculation
3781+
* @return {Float32Array[4]} the bounding box in format of [topleft_cornerx, topleft_cornery, width, height]
37813782
*/
3782-
LGraphNode.prototype.getBounding = function(out) {
3783+
LGraphNode.prototype.getBounding = function(out, compute_outer) {
37833784
out = out || new Float32Array(4);
3784-
out[0] = this.pos[0] - 4;
3785-
out[1] = this.pos[1] - LiteGraph.NODE_TITLE_HEIGHT;
3786-
out[2] = this.size[0] + 4;
3787-
out[3] = this.flags.collapsed ? LiteGraph.NODE_TITLE_HEIGHT : this.size[1] + LiteGraph.NODE_TITLE_HEIGHT;
3785+
const nodePos = this.pos;
3786+
const isCollapsed = this.flags.collapsed;
3787+
const nodeSize = this.size;
3788+
3789+
let left_offset = 0;
3790+
// 1 offset due to how nodes are rendered
3791+
let right_offset = 1 ;
3792+
let top_offset = 0;
3793+
let bottom_offset = 0;
3794+
3795+
if (compute_outer) {
3796+
// 4 offset for collapsed node connection points
3797+
left_offset = 4;
3798+
// 6 offset for right shadow and collapsed node connection points
3799+
right_offset = 6 + left_offset;
3800+
// 4 offset for collapsed nodes top connection points
3801+
top_offset = 4;
3802+
// 5 offset for bottom shadow and collapsed node connection points
3803+
bottom_offset = 5 + top_offset;
3804+
}
3805+
3806+
out[0] = nodePos[0] - left_offset;
3807+
out[1] = nodePos[1] - LiteGraph.NODE_TITLE_HEIGHT - top_offset;
3808+
out[2] = isCollapsed ?
3809+
(this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH) + right_offset :
3810+
nodeSize[0] + right_offset;
3811+
out[3] = isCollapsed ?
3812+
LiteGraph.NODE_TITLE_HEIGHT + bottom_offset :
3813+
nodeSize[1] + LiteGraph.NODE_TITLE_HEIGHT + bottom_offset;
37883814

37893815
if (this.onBounding) {
37903816
this.onBounding(out);
@@ -7673,7 +7699,7 @@ LGraphNode.prototype.executeAction = function(action)
76737699
continue;
76747700
}
76757701

7676-
if (!overlapBounding(this.visible_area, n.getBounding(temp))) {
7702+
if (!overlapBounding(this.visible_area, n.getBounding(temp, true))) {
76777703
continue;
76787704
} //out of the visible area
76797705

@@ -9975,6 +10001,7 @@ LGraphNode.prototype.executeAction = function(action)
997510001
var x = pos[0] - node.pos[0];
997610002
var y = pos[1] - node.pos[1];
997710003
var width = node.size[0];
10004+
var deltaX = event.deltaX || event.deltax || 0;
997810005
var that = this;
997910006
var ref_window = this.getCanvasWindow();
998010007

@@ -10021,8 +10048,8 @@ LGraphNode.prototype.executeAction = function(action)
1002110048
case "combo":
1002210049
var old_value = w.value;
1002310050
if (event.type == LiteGraph.pointerevents_method+"move" && w.type == "number") {
10024-
if(event.deltaX)
10025-
w.value += event.deltaX * 0.1 * (w.options.step || 1);
10051+
if(deltaX)
10052+
w.value += deltaX * 0.1 * (w.options.step || 1);
1002610053
if ( w.options.min != null && w.value < w.options.min ) {
1002710054
w.value = w.options.min;
1002810055
}
@@ -11499,7 +11526,8 @@ LGraphNode.prototype.executeAction = function(action)
1149911526
var input = dialog.querySelector("input");
1150011527
if (input) {
1150111528
input.addEventListener("blur", function(e) {
11502-
this.focus();
11529+
if(that.search_box)
11530+
this.focus();
1150311531
});
1150411532
input.addEventListener("keydown", function(e) {
1150511533
if (e.keyCode == 38) {

0 commit comments

Comments
 (0)