Skip to content

Commit db7287d

Browse files
author
sam
committed
node data accepts nodeClassList=[] and lineClassList[] (svg only)
1 parent 0139fee commit db7287d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/jsmind.graph.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ class SvgGraph {
5959
}
6060
this.lines.length = 0;
6161
}
62-
draw_line(pout, pin, offset, color) {
62+
draw_line(pout, pin, offset, color, classList) {
6363
var line = SvgGraph.c('path');
6464
line.setAttribute('stroke', color || this.opts.line_color);
6565
line.setAttribute('stroke-width', this.opts.line_width);
6666
line.setAttribute('fill', 'transparent');
67+
if (classList) {
68+
classList.forEach(className => {
69+
line.classList.add(className);
70+
});
71+
}
6772
this.lines.push(line);
6873
this.e_svg.appendChild(line);
6974
this.drawing(

src/jsmind.view_provider.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ export class ViewProvider {
505505
this._reset_node_custom_style(node._data.view.element, node.data);
506506
}
507507
_reset_node_custom_style(node_element, node_data) {
508-
if ('classList' in node_data && Array.isArray(node_data['classList'])) {
509-
node_data['classList'].forEach((className) => {
508+
if (Array.isArray(node_data['nodeClassList'])) {
509+
node_data['nodeClassList'].forEach(className => {
510510
node_element.classList.add(className);
511511
});
512512
}
@@ -591,6 +591,7 @@ export class ViewProvider {
591591
var pin = null;
592592
var pout = null;
593593
var color = null;
594+
var classList = null;
594595
var _offset = this.get_view_offset();
595596
for (var nodeid in nodes) {
596597
node = nodes[nodeid];
@@ -603,7 +604,10 @@ export class ViewProvider {
603604
pin = this.layout.get_node_point_in(node);
604605
pout = this.layout.get_node_point_out(node.parent);
605606
color = node.data['leading-line-color'];
606-
this.graph.draw_line(pout, pin, _offset, color);
607+
classList = Array.isArray(node.data['lineClassList'])
608+
? node.data['lineClassList']
609+
: null;
610+
this.graph.draw_line(pout, pin, _offset, color, classList);
607611
}
608612
}
609613
// Drag the whole mind map with your mouse, when it's larger that the container

0 commit comments

Comments
 (0)