MoveElementsHandler.js 766 B

12345678910111213141516171819202122232425262728293031323334
  1. import MoveHelper from './helper/MoveHelper';
  2. /**
  3. * A handler that implements reversible moving of shapes.
  4. */
  5. export default function MoveElementsHandler(modeling) {
  6. this._helper = new MoveHelper(modeling);
  7. }
  8. MoveElementsHandler.$inject = [ 'modeling' ];
  9. MoveElementsHandler.prototype.preExecute = function(context) {
  10. context.closure = this._helper.getClosure(context.shapes);
  11. };
  12. MoveElementsHandler.prototype.postExecute = function(context) {
  13. var hints = context.hints,
  14. primaryShape;
  15. if (hints && hints.primaryShape) {
  16. primaryShape = hints.primaryShape;
  17. hints.oldParent = primaryShape.parent;
  18. }
  19. this._helper.moveClosure(
  20. context.closure,
  21. context.delta,
  22. context.newParent,
  23. context.newHost,
  24. primaryShape
  25. );
  26. };