BendpointRules.js 860 B

12345678910111213141516171819202122232425262728293031323334
  1. import inherits from 'inherits';
  2. import RuleProvider from 'lib/features/rules/RuleProvider';
  3. export default function ConnectRules(eventBus) {
  4. RuleProvider.call(this, eventBus);
  5. }
  6. ConnectRules.$inject = ['eventBus'];
  7. inherits(ConnectRules, RuleProvider);
  8. ConnectRules.prototype.init = function() {
  9. function isSameType(connection, newSource, newTarget) {
  10. var source = newSource || connection.source,
  11. target = newTarget || connection.target;
  12. return source.type === target.type;
  13. }
  14. this.addRule('connection.reconnectStart', function(context) {
  15. return isSameType(context.connection, context.hover);
  16. });
  17. this.addRule('connection.updateWaypoints', function(context) {
  18. return null;
  19. });
  20. this.addRule('connection.reconnectEnd', function(context) {
  21. return isSameType(context.connection, null, context.hover);
  22. });
  23. };