Skip to content

Commit

Permalink
feat(selection-visuals): add marker to related elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Kiefer committed Oct 24, 2018
1 parent 372e439 commit c7f8f1a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/features/selection/SelectionVisuals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import {
forEach
} from 'min-dash';

import {
getType
} from 'lib/util/Elements';

var MARKER_HOVER = 'hover',
MARKER_SELECTED = 'selected';

Expand All @@ -22,12 +26,29 @@ export default function SelectionVisuals(events, canvas, selection, styles) {

this._multiSelectionBox = null;

function applyToRelatedElements(e, cls, fn) {

// connections -> mark related labels
if (getType(e) === 'connection') {
forEach(e.labels, function(label) {
fn(label, cls);
});
}

// label -> mark related connection
if (e.labelTarget) {
fn(e.labelTarget, cls);
}
}

function addMarker(e, cls) {
canvas.addMarker(e, cls);
applyToRelatedElements(e, cls, canvas.addMarker.bind(canvas));
}

function removeMarker(e, cls) {
canvas.removeMarker(e, cls);
applyToRelatedElements(e, cls, canvas.removeMarker.bind(canvas));
}

events.on('element.hover', function(event) {
Expand Down

0 comments on commit c7f8f1a

Please sign in to comment.