fix(snapping): remove prev/next resize constraints for unbalanced resize

This commit is contained in:
Nico Rehwaldt 2015-10-22 20:35:34 +02:00
parent de35cdc6a0
commit 4ea70a05de
3 changed files with 18 additions and 12 deletions

View File

@ -16,6 +16,18 @@ var SLIGHTLY_HIGHER_PRIORITY = 1001;
*/
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.
*/
@ -23,23 +35,17 @@ function ResizeLaneBehavior(eventBus, modeling) {
var context = event.context,
shape = context.shape,
canExecute = context.canExecute,
newBounds = context.newBounds,
balanced;
newBounds = context.newBounds;
if (is(shape, 'bpmn:Lane') || is(shape, 'bpmn:Participant')) {
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
// (important when zoom level was > 1 during move)
newBounds = roundBounds(newBounds);
// perform the actual resize
modeling.resizeLane(shape, newBounds, balanced);
modeling.resizeLane(shape, newBounds, context.balanced);
}
// stop propagation

View File

@ -230,7 +230,7 @@ function BpmnSnapping(eventBus, canvas, bpmnRules, elementRegistry) {
}
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')) {

View File

@ -59,7 +59,7 @@ var LANE_MIN_HEIGHT = 60,
LANE_BOTTOM_PADDING = 20;
function getParticipantSizeConstraints(laneShape, resizeDirection) {
function getParticipantSizeConstraints(laneShape, resizeDirection, balanced) {
var lanesRoot = getLanesRoot(laneShape);
@ -93,7 +93,7 @@ function getParticipantSizeConstraints(laneShape, resizeDirection) {
}
// 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);
}
@ -110,7 +110,7 @@ function getParticipantSizeConstraints(laneShape, resizeDirection) {
}
// 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);
}