fix(snapping): remove prev/next resize constraints for unbalanced resize
This commit is contained in:
parent
de35cdc6a0
commit
4ea70a05de
|
@ -16,6 +16,18 @@ var SLIGHTLY_HIGHER_PRIORITY = 1001;
|
||||||
*/
|
*/
|
||||||
function ResizeLaneBehavior(eventBus, modeling) {
|
function ResizeLaneBehavior(eventBus, modeling) {
|
||||||
|
|
||||||
|
eventBus.on('resize.start', SLIGHTLY_HIGHER_PRIORITY + 500, function(event) {
|
||||||
|
var context = event.context,
|
||||||
|
shape = context.shape;
|
||||||
|
|
||||||
|
if (is(shape, 'bpmn:Lane') || is(shape, 'bpmn:Participant')) {
|
||||||
|
|
||||||
|
// should we resize the opposite lane(s) in
|
||||||
|
// order to compensate for the resize operation?
|
||||||
|
context.balanced = !hasPrimaryModifier(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Intercept resize end and call resize lane function instead.
|
* Intercept resize end and call resize lane function instead.
|
||||||
*/
|
*/
|
||||||
|
@ -23,23 +35,17 @@ function ResizeLaneBehavior(eventBus, modeling) {
|
||||||
var context = event.context,
|
var context = event.context,
|
||||||
shape = context.shape,
|
shape = context.shape,
|
||||||
canExecute = context.canExecute,
|
canExecute = context.canExecute,
|
||||||
newBounds = context.newBounds,
|
newBounds = context.newBounds;
|
||||||
balanced;
|
|
||||||
|
|
||||||
if (is(shape, 'bpmn:Lane') || is(shape, 'bpmn:Participant')) {
|
if (is(shape, 'bpmn:Lane') || is(shape, 'bpmn:Participant')) {
|
||||||
|
|
||||||
if (canExecute) {
|
if (canExecute) {
|
||||||
|
|
||||||
// should we resize the opposite lane(s) in
|
|
||||||
// order to compensate for the resize operation?
|
|
||||||
balanced = !hasPrimaryModifier(event);
|
|
||||||
|
|
||||||
// ensure we have actual pixel values for new bounds
|
// ensure we have actual pixel values for new bounds
|
||||||
// (important when zoom level was > 1 during move)
|
// (important when zoom level was > 1 during move)
|
||||||
newBounds = roundBounds(newBounds);
|
newBounds = roundBounds(newBounds);
|
||||||
|
|
||||||
// perform the actual resize
|
// perform the actual resize
|
||||||
modeling.resizeLane(shape, newBounds, balanced);
|
modeling.resizeLane(shape, newBounds, context.balanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop propagation
|
// stop propagation
|
||||||
|
|
|
@ -230,7 +230,7 @@ function BpmnSnapping(eventBus, canvas, bpmnRules, elementRegistry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is(shape, 'bpmn:Lane') || is(shape, 'bpmn:Participant')) {
|
if (is(shape, 'bpmn:Lane') || is(shape, 'bpmn:Participant')) {
|
||||||
context.resizeConstraints = getParticipantSizeConstraints(shape, context.direction);
|
context.resizeConstraints = getParticipantSizeConstraints(shape, context.direction, context.balanced);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is(shape, 'bpmn:TextAnnotation')) {
|
if (is(shape, 'bpmn:TextAnnotation')) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ var LANE_MIN_HEIGHT = 60,
|
||||||
LANE_BOTTOM_PADDING = 20;
|
LANE_BOTTOM_PADDING = 20;
|
||||||
|
|
||||||
|
|
||||||
function getParticipantSizeConstraints(laneShape, resizeDirection) {
|
function getParticipantSizeConstraints(laneShape, resizeDirection, balanced) {
|
||||||
|
|
||||||
var lanesRoot = getLanesRoot(laneShape);
|
var lanesRoot = getLanesRoot(laneShape);
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ function getParticipantSizeConstraints(laneShape, resizeDirection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// max top size (based on next element)
|
// max top size (based on next element)
|
||||||
if (abs(laneTrbl.top - otherTrbl.bottom) < 10) {
|
if (balanced && abs(laneTrbl.top - otherTrbl.bottom) < 10) {
|
||||||
addMax(maxTrbl, 'top', otherTrbl.top + LANE_MIN_HEIGHT);
|
addMax(maxTrbl, 'top', otherTrbl.top + LANE_MIN_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ function getParticipantSizeConstraints(laneShape, resizeDirection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// max bottom size (based on previous element)
|
// max bottom size (based on previous element)
|
||||||
if (abs(laneTrbl.bottom - otherTrbl.top) < 10) {
|
if (balanced && abs(laneTrbl.bottom - otherTrbl.top) < 10) {
|
||||||
addMin(maxTrbl, 'bottom', otherTrbl.bottom - LANE_MIN_HEIGHT);
|
addMin(maxTrbl, 'bottom', otherTrbl.bottom - LANE_MIN_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue