jsmind 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -7
- package/docs/en/1.usage.md +8 -8
- package/docs/en/2.options.md +8 -3
- package/docs/en/3.operation.md +17 -4
- package/docs/zh/1.usage.md +7 -11
- package/docs/zh/2.options.md +6 -1
- package/docs/zh/3.operation.md +19 -5
- package/es6/jsmind.draggable-node.js +1 -1
- package/es6/jsmind.draggable-node.js.map +1 -1
- package/es6/jsmind.js +1 -1
- package/es6/jsmind.js.map +1 -1
- package/js/jsmind.draggable-node.js +35 -2
- package/js/jsmind.js +36 -12
- package/package.json +1 -1
|
@@ -23,8 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
var options = {
|
|
25
25
|
line_width: 5,
|
|
26
|
+
line_color: 'rgba(0,0,0,0.3)',
|
|
26
27
|
lookup_delay: 500,
|
|
27
|
-
lookup_interval: 80
|
|
28
|
+
lookup_interval: 80,
|
|
29
|
+
scrolling_trigger_width: 20,
|
|
30
|
+
scrolling_step_length: 10
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
jsMind.draggable = function (jm) {
|
|
@@ -45,6 +48,8 @@
|
|
|
45
48
|
this.hlookup_timer = 0;
|
|
46
49
|
this.capture = false;
|
|
47
50
|
this.moved = false;
|
|
51
|
+
this.view_panel = jm.view.e_panel;
|
|
52
|
+
this.view_panel_rect = null
|
|
48
53
|
};
|
|
49
54
|
|
|
50
55
|
jsMind.draggable.prototype = {
|
|
@@ -105,7 +110,7 @@
|
|
|
105
110
|
_magnet_shadow: function (node) {
|
|
106
111
|
if (!!node) {
|
|
107
112
|
this.canvas_ctx.lineWidth = options.line_width;
|
|
108
|
-
this.canvas_ctx.strokeStyle =
|
|
113
|
+
this.canvas_ctx.strokeStyle = options.line_color;
|
|
109
114
|
this.canvas_ctx.lineCap = 'round';
|
|
110
115
|
this._clear_lines();
|
|
111
116
|
this._canvas_lineto(node.sp.x, node.sp.y, node.np.x, node.np.y);
|
|
@@ -241,6 +246,7 @@
|
|
|
241
246
|
var node = this.jm.get_node(nodeid);
|
|
242
247
|
if (!node.isroot) {
|
|
243
248
|
this.reset_shadow(el);
|
|
249
|
+
this.view_panel_rect = this.view_panel.getBoundingClientRect()
|
|
244
250
|
this.active_node = node;
|
|
245
251
|
this.offset_x = (e.clientX || e.touches[0].clientX) / jview.actualZoom - el.offsetLeft;
|
|
246
252
|
this.offset_y = (e.clientY || e.touches[0].clientY) / jview.actualZoom - el.offsetTop;
|
|
@@ -274,6 +280,32 @@
|
|
|
274
280
|
var jview = this.jm.view;
|
|
275
281
|
var px = (e.clientX || e.touches[0].clientX) / jview.actualZoom - this.offset_x;
|
|
276
282
|
var py = (e.clientY || e.touches[0].clientY) / jview.actualZoom - this.offset_y;
|
|
283
|
+
// scrolling container axisY if drag nodes exceeding container
|
|
284
|
+
if (
|
|
285
|
+
e.clientY - this.view_panel_rect.top < options.scrolling_trigger_width &&
|
|
286
|
+
this.view_panel.scrollTop > options.scrolling_step_length
|
|
287
|
+
) {
|
|
288
|
+
this.view_panel.scrollBy(0, -options.scrolling_step_length);
|
|
289
|
+
this.offset_y += options.scrolling_step_length / jview.actualZoom;
|
|
290
|
+
} else if (
|
|
291
|
+
this.view_panel_rect.bottom - e.clientY < options.scrolling_trigger_width &&
|
|
292
|
+
this.view_panel.scrollTop <
|
|
293
|
+
this.view_panel.scrollHeight - this.view_panel_rect.height - options.scrolling_step_length
|
|
294
|
+
) {
|
|
295
|
+
this.view_panel.scrollBy(0, options.scrolling_step_length);
|
|
296
|
+
this.offset_y -= options.scrolling_step_length / jview.actualZoom;
|
|
297
|
+
}
|
|
298
|
+
// scrolling container axisX if drag nodes exceeding container
|
|
299
|
+
if (e.clientX - this.view_panel_rect.left < options.scrolling_trigger_width && this.view_panel.scrollLeft > options.scrolling_step_length) {
|
|
300
|
+
this.view_panel.scrollBy(-options.scrolling_step_length, 0);
|
|
301
|
+
this.offset_x += options.scrolling_step_length / jview.actualZoom;
|
|
302
|
+
} else if (
|
|
303
|
+
this.view_panel_rect.right - e.clientX < options.scrolling_trigger_width &&
|
|
304
|
+
this.view_panel.scrollLeft < this.view_panel.scrollWidth - this.view_panel_rect.width - options.scrolling_step_length
|
|
305
|
+
) {
|
|
306
|
+
this.view_panel.scrollBy(options.scrolling_step_length, 0);
|
|
307
|
+
this.offset_x -= options.scrolling_step_length / jview.actualZoom;
|
|
308
|
+
}
|
|
277
309
|
this.shadow.style.left = px + 'px';
|
|
278
310
|
this.shadow.style.top = py + 'px';
|
|
279
311
|
clear_selection();
|
|
@@ -302,6 +334,7 @@
|
|
|
302
334
|
}
|
|
303
335
|
this.hide_shadow();
|
|
304
336
|
}
|
|
337
|
+
this.view_panel_rect = null
|
|
305
338
|
this.moved = false;
|
|
306
339
|
this.capture = false;
|
|
307
340
|
},
|
package/js/jsmind.js
CHANGED
|
@@ -68,7 +68,8 @@
|
|
|
68
68
|
layout: {
|
|
69
69
|
hspace: 30,
|
|
70
70
|
vspace: 20,
|
|
71
|
-
pspace: 13
|
|
71
|
+
pspace: 13,
|
|
72
|
+
cousin_space: 0
|
|
72
73
|
},
|
|
73
74
|
default_event_handle: {
|
|
74
75
|
enable_mousedown_handle: true,
|
|
@@ -1033,7 +1034,8 @@
|
|
|
1033
1034
|
mode: opts.mode,
|
|
1034
1035
|
hspace: opts.layout.hspace,
|
|
1035
1036
|
vspace: opts.layout.vspace,
|
|
1036
|
-
pspace: opts.layout.pspace
|
|
1037
|
+
pspace: opts.layout.pspace,
|
|
1038
|
+
cousin_space: opts.layout.cousin_space
|
|
1037
1039
|
}
|
|
1038
1040
|
var opts_view = {
|
|
1039
1041
|
container: opts.container,
|
|
@@ -1109,7 +1111,7 @@
|
|
|
1109
1111
|
var element = e.target || event.srcElement;
|
|
1110
1112
|
var nodeid = this.view.get_binded_nodeid(element);
|
|
1111
1113
|
if (!!nodeid) {
|
|
1112
|
-
if (
|
|
1114
|
+
if (this.view.is_node(element)) {
|
|
1113
1115
|
this.select_node(nodeid);
|
|
1114
1116
|
}
|
|
1115
1117
|
} else {
|
|
@@ -1122,8 +1124,8 @@
|
|
|
1122
1124
|
return;
|
|
1123
1125
|
}
|
|
1124
1126
|
var element = e.target || event.srcElement;
|
|
1125
|
-
var
|
|
1126
|
-
if (
|
|
1127
|
+
var is_expander = this.view.is_expander(element);
|
|
1128
|
+
if (is_expander) {
|
|
1127
1129
|
var nodeid = this.view.get_binded_nodeid(element);
|
|
1128
1130
|
if (!!nodeid) {
|
|
1129
1131
|
this.toggle_node(nodeid);
|
|
@@ -1137,9 +1139,12 @@
|
|
|
1137
1139
|
}
|
|
1138
1140
|
if (this.get_editable()) {
|
|
1139
1141
|
var element = e.target || event.srcElement;
|
|
1140
|
-
var
|
|
1141
|
-
if (
|
|
1142
|
-
this.
|
|
1142
|
+
var is_node = this.view.is_node(element);
|
|
1143
|
+
if (is_node) {
|
|
1144
|
+
var nodeid = this.view.get_binded_nodeid(element);
|
|
1145
|
+
if (!!nodeid) {
|
|
1146
|
+
this.begin_edit(nodeid);
|
|
1147
|
+
}
|
|
1143
1148
|
}
|
|
1144
1149
|
}
|
|
1145
1150
|
},
|
|
@@ -1879,6 +1884,9 @@
|
|
|
1879
1884
|
this.set_visible(node.children, false);
|
|
1880
1885
|
}
|
|
1881
1886
|
node_outer_height = Math.max(node._data.view.height, node_outer_height);
|
|
1887
|
+
if (node.children.length > 1) {
|
|
1888
|
+
node_outer_height += this.opts.cousin_space;
|
|
1889
|
+
}
|
|
1882
1890
|
|
|
1883
1891
|
layout_data.outer_height = node_outer_height;
|
|
1884
1892
|
layout_data.offset_y = base_y - node_outer_height / 2;
|
|
@@ -1924,6 +1932,9 @@
|
|
|
1924
1932
|
node_outer_height = 0;
|
|
1925
1933
|
}
|
|
1926
1934
|
node_outer_height = Math.max(node._data.view.height, node_outer_height);
|
|
1935
|
+
if (node.children.length > 1) {
|
|
1936
|
+
node_outer_height += this.opts.cousin_space;
|
|
1937
|
+
}
|
|
1927
1938
|
|
|
1928
1939
|
layout_data.outer_height = node_outer_height;
|
|
1929
1940
|
layout_data.offset_y = base_y - node_outer_height / 2;
|
|
@@ -2364,16 +2375,29 @@
|
|
|
2364
2375
|
return null;
|
|
2365
2376
|
}
|
|
2366
2377
|
var tagName = element.tagName.toLowerCase();
|
|
2367
|
-
if (tagName == 'jmnodes' || tagName == 'body' || tagName == 'html') {
|
|
2368
|
-
return null;
|
|
2369
|
-
}
|
|
2370
2378
|
if (tagName == 'jmnode' || tagName == 'jmexpander') {
|
|
2371
2379
|
return element.getAttribute('nodeid');
|
|
2380
|
+
} else if (tagName == 'jmnodes' || tagName == 'body' || tagName == 'html') {
|
|
2381
|
+
return null;
|
|
2372
2382
|
} else {
|
|
2373
2383
|
return this.get_binded_nodeid(element.parentElement);
|
|
2374
2384
|
}
|
|
2375
2385
|
},
|
|
2376
2386
|
|
|
2387
|
+
is_node: function (element) {
|
|
2388
|
+
if (element == null) {
|
|
2389
|
+
return false;
|
|
2390
|
+
}
|
|
2391
|
+
var tagName = element.tagName.toLowerCase();
|
|
2392
|
+
if (tagName == 'jmnode') {
|
|
2393
|
+
return true;
|
|
2394
|
+
} else if (tagName == 'jmnodes' || tagName == 'body' || tagName == 'html') {
|
|
2395
|
+
return false;
|
|
2396
|
+
} else {
|
|
2397
|
+
return this.is_node(element.parentElement);
|
|
2398
|
+
}
|
|
2399
|
+
},
|
|
2400
|
+
|
|
2377
2401
|
is_expander: function (element) {
|
|
2378
2402
|
return (element.tagName.toLowerCase() == 'jmexpander');
|
|
2379
2403
|
},
|
|
@@ -3085,8 +3109,8 @@
|
|
|
3085
3109
|
}
|
|
3086
3110
|
};
|
|
3087
3111
|
|
|
3088
|
-
// quick way
|
|
3089
3112
|
jm.show = function (options, mind) {
|
|
3113
|
+
logger.warn('`jsMind.show(options, mind)` is deprecated, please use `jm = new jsMind(options); jm.show(mind);` instead')
|
|
3090
3114
|
var _jm = new jm(options);
|
|
3091
3115
|
_jm.show(mind);
|
|
3092
3116
|
return _jm;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsmind",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "jsMind is a pure javascript library for mindmap, it base on html5 canvas. jsMind was released under BSD license, you can embed it in any project, if only you observe the license.",
|
|
5
5
|
"main": "js/jsmind.js",
|
|
6
6
|
"directories": {
|