-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathModelingUtil.js
55 lines (43 loc) · 1.13 KB
/
ModelingUtil.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { isString } from 'min-dash';
export { is, isAny } from '../../../util/ModelUtil';
import { isAny } from '../../../util/ModelUtil';
import { isHorizontal } from '../../../util/DiUtil';
/**
* @typedef {import('../../../model/Types').Element} Element
*/
/**
* Return the parent of the element with any of the given types.
*
* @param {Element} element
* @param {string|string[]} anyType
*
* @return {Element|null}
*/
export function getParent(element, anyType) {
if (isString(anyType)) {
anyType = [ anyType ];
}
while ((element = element.parent)) {
if (isAny(element, anyType)) {
return element;
}
}
return null;
}
/**
* Determines if the local modeling direction is vertical or horizontal.
*
* @param {Element} element
*
* @return {boolean} false for vertical pools, lanes and their children. true otherwise
*/
export function isDirectionHorizontal(element) {
var types = [ 'bpmn:Participant', 'bpmn:Lane' ];
var parent = getParent(element, types);
if (parent) {
return isHorizontal(parent);
} else if (isAny(element, types)) {
return isHorizontal(element);
}
return true;
}