LayoutConnectionHandler.js 783 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { assign } from 'min-dash';
  2. /**
  3. * A handler that implements reversible moving of shapes.
  4. */
  5. export default function LayoutConnectionHandler(layouter, canvas) {
  6. this._layouter = layouter;
  7. this._canvas = canvas;
  8. }
  9. LayoutConnectionHandler.$inject = [ 'layouter', 'canvas' ];
  10. LayoutConnectionHandler.prototype.execute = function(context) {
  11. var connection = context.connection;
  12. var oldWaypoints = connection.waypoints;
  13. assign(context, {
  14. oldWaypoints: oldWaypoints
  15. });
  16. connection.waypoints = this._layouter.layoutConnection(connection, context.hints);
  17. return connection;
  18. };
  19. LayoutConnectionHandler.prototype.revert = function(context) {
  20. var connection = context.connection;
  21. connection.waypoints = context.oldWaypoints;
  22. return connection;
  23. };