function AutoResize(eventBus, elementRegistry, modeling, rules) {

  CommandInterceptor.call(this, eventBus);

  this._elementRegistry = elementRegistry;
  this._modeling = modeling;
  this._rules = rules;

  var self = this;

  this.postExecuted([ 'shape.create' ], function(event) {
    var context = event.context,
        hints = context.hints || {},
        shape = context.shape,
        parent = context.parent || context.newParent;

    if (hints.autoResize === false) {
      return;
    }

    self._expand([ shape ], parent);
  });

  this.postExecuted([ 'elements.move' ], function(event) {
    var context = event.context,
        elements = flatten(values(context.closure.topLevel)),
        hints = context.hints;

    var autoResize = hints ? hints.autoResize : true;

    if (autoResize === false) {
      return;
    }

    var expandings = groupBy(elements, function(element) {
      return element.parent.id;
    });

    forEach(expandings, function(elements, parentId) {

      // optionally filter elements to be considered when resizing
      if (isArray(autoResize)) {
        elements = elements.filter(function(element) {
          return find(autoResize, matchPattern({ id: element.id }));
        });
      }

      self._expand(elements, parentId);
    });
  });

  this.postExecuted([ 'shape.toggleCollapse' ], function(event) {
    var context = event.context,
        hints = context.hints,
        shape = context.shape;

    if (hints && hints.autoResize === false) {
      return;
    }

    if (shape.collapsed) {
      return;
    }

    self._expand(shape.children || [], shape);
  });

  this.postExecuted([ 'shape.resize' ], function(event) {
    var context = event.context,
        hints = context.hints,
        shape = context.shape,
        parent = shape.parent;

    if (hints && hints.autoResize === false) {
      return;
    }

    if (parent) {
      self._expand([ shape ], parent);
    }
  });

}
/**
 * An auto resize component that takes care of expanding a parent element
 * if child elements are created or moved close the parents edge.
 *
 * @param {EventBus} eventBus
 * @param {ElementRegistry} elementRegistry
 * @param {Modeling} modeling
 * @param {Rules} rules
 */
An auto resize component that takes care of expanding a parent element
if child elements are created or moved close the parents edge.


An auto resize component that takes care of expanding a parent element if child elements are created or moved close the parents edge .
function AutoResize(eventBus, elementRegistry, modeling, rules) {
  CommandInterceptor.call(this, eventBus);
  this._elementRegistry = elementRegistry;
  this._modeling = modeling;
  this._rules = rules;
  var self = this;
  this.postExecuted([ 'shape.create' ], function(event) {
    var context = event.context,
        hints = context.hints || {},
        shape = context.shape,
        parent = context.parent || context.newParent;
    if (hints.autoResize === false) {
      return;
    }
    self._expand([ shape ], parent);
  });
  this.postExecuted([ 'elements.move' ], function(event) {
    var context = event.context,
        elements = flatten(values(context.closure.topLevel)),
        hints = context.hints;
    var autoResize = hints ? hints.autoResize : true;
    if (autoResize === false) {
      return;
    }
    var expandings = groupBy(elements, function(element) {
      return element.parent.id;
    });
    forEach(expandings, function(elements, parentId) {
      if (isArray(autoResize)) {
        elements = elements.filter(function(element) {
          return find(autoResize, matchPattern({ id: element.id }));
        });
      }
      self._expand(elements, parentId);
    });
  });
  this.postExecuted([ 'shape.toggleCollapse' ], function(event) {
    var context = event.context,
        hints = context.hints,
        shape = context.shape;
    if (hints && hints.autoResize === false) {
      return;
    }
    if (shape.collapsed) {
      return;
    }
    self._expand(shape.children || [], shape);
  });
  this.postExecuted([ 'shape.resize' ], function(event) {
    var context = event.context,
        hints = context.hints,
        shape = context.shape,
        parent = shape.parent;
    if (hints && hints.autoResize === false) {
      return;
    }
    if (parent) {
      self._expand([ shape ], parent);
    }
  });
}
function AutoResize ( eventBus , elementRegistry , modeling , rules ) { CommandInterceptor . call ( this , eventBus ) ; this . _elementRegistry = elementRegistry ; this . _modeling = modeling ; this . _rules = rules ; var self = this ; this . postExecuted ( [ 'shape.create' ] , function ( event ) { var context = event . context , hints = context . hints || { } , shape = context . shape , parent = context . parent || context . newParent ; if ( hints . autoResize === false ) { return ; } self . _expand ( [ shape ] , parent ) ; } ) ; this . postExecuted ( [ 'elements.move' ] , function ( event ) { var context = event . context , elements = flatten ( values ( context . closure . topLevel ) ) , hints = context . hints ; var autoResize = hints ? hints . autoResize : true ; if ( autoResize === false ) { return ; } var expandings = groupBy ( elements , function ( element ) { return element . parent . id ; } ) ; forEach ( expandings , function ( elements , parentId ) { if ( isArray ( autoResize ) ) { elements = elements . filter ( function ( element ) { return find ( autoResize , matchPattern ( { id : element . id } ) ) ; } ) ; } self . _expand ( elements , parentId ) ; } ) ; } ) ; this . postExecuted ( [ 'shape.toggleCollapse' ] , function ( event ) { var context = event . context , hints = context . hints , shape = context . shape ; if ( hints && hints . autoResize === false ) { return ; } if ( shape . collapsed ) { return ; } self . _expand ( shape . children || [ ] , shape ) ; } ) ; this . postExecuted ( [ 'shape.resize' ] , function ( event ) { var context = event . context , hints = context . hints , shape = context . shape , parent = shape . parent ; if ( hints && hints . autoResize === false ) { return ; } if ( parent ) { self . _expand ( [ shape ] , parent ) ; } } ) ; }
An auto resize component that takes care of expanding a parent element
 if child elements are created or moved close the parents edge.
An auto resize component that takes care of expanding a parent element if child elements are created or moved close the parents edge .
// optionally filter elements to be considered when resizing