Skip to content

Commit

Permalink
fix bug: draggable-node plugin block dblclick to trigger the edit mode (
Browse files Browse the repository at this point in the history
  • Loading branch information
hizzgdev authored Oct 16, 2023
1 parent 016a04b commit 0fe4008
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/plugins/jsmind.draggable-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const clear_selection =
const DEFAULT_OPTIONS = {
line_width: 5,
line_color: 'rgba(0,0,0,0.3)',
drag_start_delay: 100,
lookup_delay: 500,
lookup_interval: 80,
scrolling_trigger_width: 20,
Expand Down Expand Up @@ -55,6 +56,7 @@ class DraggableNode {
this.offset_y = 0;
this.hlookup_delay = 0;
this.hlookup_timer = 0;
this.hdrag_start_delay = 0;
this.capture = false;
this.moved = false;
this.canvas_draggable = jm.get_view_draggable();
Expand Down Expand Up @@ -206,26 +208,40 @@ class DraggableNode {
var container = this.jm.view.container;
$.on(container, 'mousedown', function (e) {
var evt = e || event;
jd.dragstart.call(jd, evt);
jd.hdrag_start_delay = $.w.setTimeout(function () {
jd.hdrag_start_delay = 0;
jd.dragstart.call(jd, evt);
}, jd.options.drag_start_delay);
});
$.on(container, 'mousemove', function (e) {
var evt = e || event;
jd.drag.call(jd, evt);
});
$.on(container, 'mouseup', function (e) {
var evt = e || event;
if (jd.hdrag_start_delay != 0) {
$.w.clearTimeout(jd.hdrag_start_delay);
jd.hdrag_start_delay = 0;
}
jd.dragend.call(jd, evt);
});
$.on(container, 'touchstart', function (e) {
var evt = e || event;
jd.dragstart.call(jd, evt);
jd.hdrag_start_delay = $.w.setTimeout(function () {
jd.hdrag_start_delay = 0;
jd.dragstart.call(jd, evt);
}, jd.options.drag_start_delay);
});
$.on(container, 'touchmove', function (e) {
var evt = e || event;
jd.drag.call(jd, evt);
});
$.on(container, 'touchend', function (e) {
var evt = e || event;
if (jd.hdrag_start_delay != 0) {
$.w.clearTimeout(jd.hdrag_start_delay);
jd.hdrag_start_delay = 0;
}
jd.dragend.call(jd, evt);
});
}
Expand Down Expand Up @@ -273,9 +289,7 @@ class DraggableNode {
jd.lookup_close_node.call(jd);
}, jd.options.lookup_interval);
}, this.options.lookup_delay);
$.w.setTimeout(function () {
jd.capture = true;
}, 0);
jd.capture = true;
}
}
}
Expand Down

0 comments on commit 0fe4008

Please sign in to comment.