MoveRules.js 665 B

12345678910111213141516171819202122232425262728293031
  1. import inherits from 'inherits';
  2. import RuleProvider from 'lib/features/rules/RuleProvider';
  3. export default function MoveRules(eventBus) {
  4. RuleProvider.call(this, eventBus);
  5. }
  6. MoveRules.$inject = [ 'eventBus' ];
  7. inherits(MoveRules, RuleProvider);
  8. MoveRules.prototype.init = function() {
  9. this.addRule('elements.move', function(context) {
  10. var target = context.target,
  11. shapes = context.shapes;
  12. // check that we do not accidently try to drop elements
  13. // onto themselves or children of themselves
  14. while (target) {
  15. if (shapes.indexOf(target) !== -1) {
  16. return false;
  17. }
  18. target = target.parent;
  19. }
  20. });
  21. };