# all files / Github/diagram-js/lib/features/modeling/cmd/ MoveElementsHandler.js

100% Statements 10/10
100% Branches 4/4
100% Functions 3/3
100% Lines 10/10

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34

    1128×

    1×

    1×
    406×

    1×

    406×

    406×
    36×
    36×

    406×

     import MoveHelper from './helper/MoveHelper';

    /**
     * A handler that implements reversible moving of shapes.
     */
    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
      );
    };