jstd-web/node_modules/diagram-js/lib/features/modeling/cmd/MoveElementsHandler.js

39 lines
860 B
JavaScript
Raw Normal View History

2025-11-25 15:23:22 +08:00
import MoveHelper from './helper/MoveHelper';
/**
* @typedef {import('../Modeling').default} Modeling
*/
/**
* A handler that implements reversible moving of shapes.
*
* @param {Modeling} modeling
*/
export default function MoveElementsHandler(modeling) {
this._helper = new MoveHelper(modeling);
}
MoveElementsHandler.$inject = [ 'modeling' ];
MoveElementsHandler.prototype.preExecute = function(context) {
context.closure = this._helper.getClosure(context.shapes);
};
MoveElementsHandler.prototype.postExecute = function(context) {
var hints = context.hints,
primaryShape;
if (hints && hints.primaryShape) {
primaryShape = hints.primaryShape;
hints.oldParent = primaryShape.parent;
}
this._helper.moveClosure(
context.closure,
context.delta,
context.newParent,
context.newHost,
primaryShape
);
};