bpmn-js 17.0.1 → 17.1.0

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.
@@ -3,6 +3,10 @@ import {
3
3
  LANE_INDENTATION
4
4
  } from '../util/LaneUtil';
5
5
 
6
+ import {
7
+ isHorizontal
8
+ } from '../../../util/DiUtil';
9
+
6
10
  /**
7
11
  * @typedef {import('diagram-js/lib/command/CommandHandler').default} CommandHandler
8
12
  *
@@ -45,36 +49,41 @@ SplitLaneHandler.prototype.preExecute = function(context) {
45
49
  throw new Error(translate('more than {count} child lanes', { count: newLanesCount }));
46
50
  }
47
51
 
48
- var newLanesHeight = Math.round(shape.height / newLanesCount);
52
+ var isHorizontalLane = isHorizontal(shape);
49
53
 
50
- // Iterate from top to bottom in child lane order,
54
+ var laneBaseSize = isHorizontalLane ? shape.height : shape.width;
55
+ var newLanesSize = Math.round(laneBaseSize / newLanesCount);
56
+
57
+ // Iterate from first to last in child lane order,
51
58
  // resizing existing lanes and creating new ones
52
59
  // so that they split the parent proportionally.
53
60
  //
54
- // Due to rounding related errors, the bottom lane
61
+ // Due to rounding related errors, the last lane
55
62
  // needs to take up all the remaining space.
56
- var laneY,
57
- laneHeight,
63
+ var laneSize,
58
64
  laneBounds,
59
65
  newLaneAttrs,
60
66
  idx;
61
67
 
62
68
  for (idx = 0; idx < newLanesCount; idx++) {
63
69
 
64
- laneY = shape.y + idx * newLanesHeight;
65
-
66
- // if bottom lane
70
+ // if last lane
67
71
  if (idx === newLanesCount - 1) {
68
- laneHeight = shape.height - (newLanesHeight * idx);
72
+ laneSize = laneBaseSize - (newLanesSize * idx);
69
73
  } else {
70
- laneHeight = newLanesHeight;
74
+ laneSize = newLanesSize;
71
75
  }
72
76
 
73
- laneBounds = {
77
+ laneBounds = isHorizontalLane ? {
74
78
  x: shape.x + LANE_INDENTATION,
75
- y: laneY,
79
+ y: shape.y + idx * newLanesSize,
76
80
  width: shape.width - LANE_INDENTATION,
77
- height: laneHeight
81
+ height: laneSize
82
+ } : {
83
+ x: shape.x + idx * newLanesSize,
84
+ y: shape.y + LANE_INDENTATION,
85
+ width: laneSize,
86
+ height: shape.height - LANE_INDENTATION
78
87
  };
79
88
 
80
89
  if (idx < existingLanesCount) {
@@ -85,7 +94,8 @@ SplitLaneHandler.prototype.preExecute = function(context) {
85
94
 
86
95
  // create a new lane at position
87
96
  newLaneAttrs = {
88
- type: 'bpmn:Lane'
97
+ type: 'bpmn:Lane',
98
+ isHorizontal: isHorizontalLane
89
99
  };
90
100
 
91
101
  modeling.createShape(newLaneAttrs, laneBounds, shape);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmn-js",
3
- "version": "17.0.1",
3
+ "version": "17.1.0",
4
4
  "description": "A bpmn 2.0 toolkit and web modeler",
5
5
  "main": "index.js",
6
6
  "files": [