mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-11 17:44:12 +00:00
fix(drilldown): set currentRoot on collaboration change
This commit is contained in:
parent
cf6cbfca4a
commit
c1082b567d
@ -14,7 +14,9 @@ export default function DrilldownCentering(eventBus, canvas) {
|
||||
var positionMap = new Map();
|
||||
|
||||
eventBus.on('root.set', function(event) {
|
||||
var newRoot = event.element;
|
||||
var currentViewbox = canvas.viewbox();
|
||||
var storedViewbox = positionMap.get(newRoot);
|
||||
|
||||
positionMap.set(currentRoot, {
|
||||
x: currentViewbox.x,
|
||||
@ -22,8 +24,7 @@ export default function DrilldownCentering(eventBus, canvas) {
|
||||
zoom: currentViewbox.scale
|
||||
});
|
||||
|
||||
var newRoot = event.element;
|
||||
var storedViewbox = positionMap.get(newRoot);
|
||||
currentRoot = newRoot;
|
||||
|
||||
// current root was replaced with a collaboration, we don't update the viewbox
|
||||
if (is(newRoot, 'bpmn:Collaboration') && !storedViewbox) {
|
||||
@ -45,12 +46,6 @@ export default function DrilldownCentering(eventBus, canvas) {
|
||||
if (storedViewbox.zoom !== currentViewbox.scale) {
|
||||
canvas.zoom(storedViewbox.zoom, { x: 0, y: 0 });
|
||||
}
|
||||
|
||||
currentRoot = newRoot;
|
||||
});
|
||||
|
||||
eventBus.on('root.remove', function(event) {
|
||||
positionMap.remove(event.element);
|
||||
});
|
||||
|
||||
eventBus.on('diagram.clear', function() {
|
||||
|
@ -20,7 +20,15 @@ describe('features - drilldown', function() {
|
||||
|
||||
beforeEach(bootstrapModeler(multiLayerXML, { modules: testModules }));
|
||||
|
||||
describe('Navigation', function() {
|
||||
describe('Navigation - Collaboration', function() {
|
||||
|
||||
var process, participant;
|
||||
|
||||
beforeEach(inject(function(canvas, elementFactory) {
|
||||
process = canvas.getRootElement();
|
||||
participant = elementFactory.createParticipantShape({ x: 100, y: 100 });
|
||||
}));
|
||||
|
||||
|
||||
it('should not reset scroll on create collaboration',
|
||||
inject(function(canvas, modeling) {
|
||||
@ -31,7 +39,8 @@ describe('features - drilldown', function() {
|
||||
var zoomedAndScrolledViewbox = canvas.viewbox();
|
||||
|
||||
// when
|
||||
modeling.makeCollaboration();
|
||||
modeling.createShape(participant, { x: 0, y: 0 }, process);
|
||||
|
||||
|
||||
// then
|
||||
expectViewbox(zoomedAndScrolledViewbox);
|
||||
@ -48,7 +57,7 @@ describe('features - drilldown', function() {
|
||||
var zoomedAndScrolledViewbox = canvas.viewbox();
|
||||
|
||||
// when
|
||||
modeling.makeCollaboration();
|
||||
modeling.createShape(participant, { x: 0, y: 0 }, process);
|
||||
commandStack.undo();
|
||||
|
||||
// then
|
||||
@ -66,7 +75,7 @@ describe('features - drilldown', function() {
|
||||
var zoomedAndScrolledViewbox = canvas.viewbox();
|
||||
|
||||
// when
|
||||
modeling.makeCollaboration();
|
||||
modeling.createShape(participant, { x: 400, y: 225 }, process);
|
||||
commandStack.undo();
|
||||
commandStack.redo();
|
||||
|
||||
@ -75,6 +84,28 @@ describe('features - drilldown', function() {
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
it('should remember scroll and zoom after morph', inject(function(canvas, modeling) {
|
||||
|
||||
// given
|
||||
canvas.scroll({ dx: 500, dy: 500 });
|
||||
canvas.zoom(0.5);
|
||||
var zoomedAndScrolledViewbox = canvas.viewbox();
|
||||
|
||||
modeling.createShape(participant, { x: 400, y: 225 }, process);
|
||||
var collaboration = canvas.getRootElement();
|
||||
|
||||
// when
|
||||
canvas.setRootElement(canvas.findRoot('collapsedProcess_plane'));
|
||||
canvas.setRootElement(collaboration);
|
||||
|
||||
// then
|
||||
var newViewbox = canvas.viewbox();
|
||||
expect(newViewbox.x).to.eql(zoomedAndScrolledViewbox.x);
|
||||
expect(newViewbox.y).to.eql(zoomedAndScrolledViewbox.y);
|
||||
expect(newViewbox.scale).to.eql(zoomedAndScrolledViewbox.scale);
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user