fix(auto-resize): allow concurrent top/bottom or left/right expanding

This commit is contained in:
pedesen 2015-09-23 15:00:05 +02:00 committed by Ricardo Matias
parent dc78909227
commit 02af025a2e
3 changed files with 23 additions and 11 deletions

View File

@ -29,7 +29,7 @@ function AutoResize(eventBus, canvas, modeling){
shape = context.shape,
parent = context.parent || context.newParent;
expand([shape], parent);
expand([ shape ], parent);
});
this.postExecuted([ 'elements.move' ], function(event) {
@ -49,8 +49,7 @@ function AutoResize(eventBus, canvas, modeling){
*/
if (oldParent && oldParent === parent &&
primaryShape && primaryShape.parent === parent &&
element.parent !== parent
) {
element.parent !== parent) {
return;
}
elements.push(element);
@ -119,20 +118,20 @@ function AutoResize(eventBus, canvas, modeling){
if (inbounds.top) {
var topPosition = bbox.y - OFFSET.top;
assign(newBounds, { y: topPosition, height: target.height + target.y - topPosition });
assign(newBounds, { y: topPosition, height: newBounds.height + newBounds.y - topPosition });
}
if (inbounds.bottom) {
assign(newBounds, { height: bbox.y + bbox.height + OFFSET.bottom - target.y });
assign(newBounds, { height: bbox.y + bbox.height + OFFSET.bottom - newBounds.y });
}
if (inbounds.left) {
var leftPosition = bbox.x - OFFSET.left;
assign(newBounds, { x: leftPosition, width: target.width + target.x - leftPosition });
assign(newBounds, { x: leftPosition, width: newBounds.width + newBounds.x - leftPosition });
}
if (inbounds.right) {
assign(newBounds, { width: bbox.x + bbox.width + OFFSET.right - target.x });
assign(newBounds, { width: bbox.x + bbox.width + OFFSET.right - newBounds.x });
}
modeling.resizeShape(target, newBounds);
@ -141,7 +140,7 @@ function AutoResize(eventBus, canvas, modeling){
// recursively expand parent elements
if (parent) {
expand([target], parent);
expand([ target ], parent);
}
}
}

View File

@ -1,8 +1,6 @@
'use strict';
var groupBy = require('lodash/collection/groupBy'),
size = require('lodash/collection/size'),
find = require('lodash/collection/find'),
var find = require('lodash/collection/find'),
any = require('lodash/collection/any'),
forEach = require('lodash/collection/forEach'),
inherits = require('inherits');

View File

@ -486,6 +486,21 @@ describe('features/auto-resize', function() {
}));
it('should expand top and bottom edge, if primary shape changes parent', inject(function(modeling){
// given
var originalBounds = getBounds(subProcessShape_1);
// when
modeling.moveElements([ taskShape_1, taskShape_2 ],
{ x: 0, y: 100 }, subProcessShape_1, { primaryShape: taskShape_2 });
// then
var expectedBounds = assign(originalBounds, { y: 130, height: 334 });
expect(subProcessShape_1).to.have.bounds(expectedBounds);
}));
});
describe('nested sub processes', function() {