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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | 1× 1× 1189× 270× 270× 270× 270× 6× 6× 270× 270× 12× 12× 1189× 17× 17× 2× 2× 1189× 10× 10× 10× 10× 2× 2× 1189× 16× 16× 16× 1× 1189× 52× 52× 1× 1× | import { getLanesRoot } from '../util/LaneUtil'; import { is } from '../../../util/ModelUtil'; import { isAny } from '../util/ModelingUtil'; var HIGH_PRIORITY = 1500; var HIGHEST_PRIORITY = 2000; /** * Correct hover targets in certain situations to improve diagram interaction. * * @param {ElementRegistry} elementRegistry * @param {EventBus} eventBus * @param {Canvas} canvas */ export default function FixHoverBehavior(elementRegistry, eventBus, canvas) { eventBus.on([ 'create.hover', 'create.move', 'create.end', 'shape.move.hover', 'shape.move.move', 'shape.move.end' ], HIGH_PRIORITY, function(event) { var context = event.context, shape = context.shape || event.shape, hover = event.hover; // ensure elements are not dropped onto a bpmn:Lane but onto // the underlying bpmn:Participant if (is(hover, 'bpmn:Lane') && !isAny(shape, [ 'bpmn:Lane', 'bpmn:Participant' ])) { event.hover = getLanesRoot(hover); event.hoverGfx = elementRegistry.getGraphics(event.hover); } var rootElement = canvas.getRootElement(); // ensure bpmn:Group and label elements are dropped // always onto the root if (hover !== rootElement && (shape.labelTarget || is(shape, 'bpmn:Group'))) { event.hover = rootElement; event.hoverGfx = elementRegistry.getGraphics(event.hover); } }); eventBus.on([ 'connect.hover', 'global-connect.hover' ], HIGH_PRIORITY, function(event) { var hover = event.hover; // ensure connections start/end on bpmn:Participant, // not the underlying bpmn:Lane if (is(hover, 'bpmn:Lane')) { event.hover = getLanesRoot(hover) || hover; event.hoverGfx = elementRegistry.getGraphics(event.hover); } }); eventBus.on([ 'bendpoint.move.hover' ], HIGH_PRIORITY, function(event) { var context = event.context, type = context.type, hover = event.hover; // ensure reconnect start/end on bpmn:Participant, // not the underlying bpmn:Lane if (is(hover, 'bpmn:Lane') && /reconnect/.test(type)) { event.hover = getLanesRoot(hover) || hover; event.hoverGfx = elementRegistry.getGraphics(event.hover); } }); eventBus.on([ 'connect.start' ], HIGH_PRIORITY, function(event) { var context = event.context, source = context.source; // ensure connect start on bpmn:Participant, // not the underlying bpmn:Lane if (is(source, 'bpmn:Lane')) { context.source = getLanesRoot(source) || source; } }); // allow movement of participants from lanes eventBus.on('shape.move.start', HIGHEST_PRIORITY, function(event) { var shape = event.shape; if (is(shape, 'bpmn:Lane')) { event.shape = getLanesRoot(shape) || shape; } }); } FixHoverBehavior.$inject = [ 'elementRegistry', 'eventBus', 'canvas' ]; |