bpmn-js/lib/features/modeling/ModelingUtil.js
Nico Rehwaldt b233ab957c feat(snapping): add bpmn-specific move snapping
This commit adds message flow + collaboration specific snapping by
subclassing the diagram-js provided default Snapping implementation.

* Add collaboration snapping
* Rename lib/util/{Name}.js -> lib/util/{Name}Util.js

Closes #255
2015-04-29 15:04:54 +02:00

34 lines
533 B
JavaScript

'use strict';
var find = require('lodash/collection/find');
function getParents(element) {
var parents = [];
while (element) {
element = element.parent;
if (element) {
parents.push(element);
}
}
return parents;
}
module.exports.getParents = getParents;
function getSharedParent(a, b) {
var parentsA = getParents(a),
parentsB = getParents(b);
return find(parentsA, function(parent) {
return parentsB.indexOf(parent) !== -1;
});
}
module.exports.getSharedParent = getSharedParent;