mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-01-12 18:14:40 +00:00
ab56fc21ad
This implements custom hit areas for participants, lanes and expanded subprocesses. Given these changes, users need to grab container elements on the boarder or the label area to move them. Closes https://github.com/bpmn-io/bpmn-js/issues/957
106 lines
2.3 KiB
JavaScript
106 lines
2.3 KiB
JavaScript
import { is } from '../../util/ModelUtil';
|
|
|
|
import { isExpanded } from '../../util/DiUtil';
|
|
|
|
var LABEL_WIDTH = 30,
|
|
LABEL_HEIGHT = 30;
|
|
|
|
|
|
/**
|
|
* BPMN-specific hit zones and interaction fixes.
|
|
*
|
|
* @param {EventBus} eventBus
|
|
* @param {InteractionEvents} interactionEvents
|
|
*/
|
|
export default function BpmnInteractionEvents(eventBus, interactionEvents) {
|
|
|
|
this._interactionEvents = interactionEvents;
|
|
|
|
var self = this;
|
|
|
|
eventBus.on([
|
|
'interactionEvents.createHit',
|
|
'interactionEvents.updateHit'
|
|
], function(context) {
|
|
var element = context.element,
|
|
gfx = context.gfx;
|
|
|
|
if (is(element, 'bpmn:Lane')) {
|
|
return self.createParticipantHit(element, gfx);
|
|
} else
|
|
|
|
if (is(element, 'bpmn:Participant')) {
|
|
if (isExpanded(element)) {
|
|
return self.createParticipantHit(element, gfx);
|
|
} else {
|
|
return self.createDefaultHit(element, gfx);
|
|
}
|
|
} else
|
|
|
|
if (is(element, 'bpmn:SubProcess')) {
|
|
if (isExpanded(element)) {
|
|
return self.createSubProcessHit(element, gfx);
|
|
} else {
|
|
return self.createDefaultHit(element, gfx);
|
|
}
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
BpmnInteractionEvents.$inject = [
|
|
'eventBus',
|
|
'interactionEvents'
|
|
];
|
|
|
|
|
|
BpmnInteractionEvents.prototype.createDefaultHit = function(element, gfx) {
|
|
this._interactionEvents.removeHits(gfx);
|
|
|
|
this._interactionEvents.createDefaultHit(element, gfx);
|
|
|
|
// indicate that we created a hit
|
|
return true;
|
|
};
|
|
|
|
BpmnInteractionEvents.prototype.createParticipantHit = function(element, gfx) {
|
|
|
|
// remove existing hits
|
|
this._interactionEvents.removeHits(gfx);
|
|
|
|
// add outline hit
|
|
this._interactionEvents.createBoxHit(gfx, 'click-stroke', {
|
|
width: element.width,
|
|
height: element.height
|
|
});
|
|
|
|
// add label hit
|
|
this._interactionEvents.createBoxHit(gfx, 'all', {
|
|
width: LABEL_WIDTH,
|
|
height: element.height
|
|
});
|
|
|
|
// indicate that we created a hit
|
|
return true;
|
|
};
|
|
|
|
BpmnInteractionEvents.prototype.createSubProcessHit = function(element, gfx) {
|
|
|
|
// remove existing hits
|
|
this._interactionEvents.removeHits(gfx);
|
|
|
|
// add outline hit
|
|
this._interactionEvents.createBoxHit(gfx, 'click-stroke', {
|
|
width: element.width,
|
|
height: element.height
|
|
});
|
|
|
|
// add label hit
|
|
this._interactionEvents.createBoxHit(gfx, 'all', {
|
|
width: element.width,
|
|
height: LABEL_HEIGHT
|
|
});
|
|
|
|
// indicate that we created a hit
|
|
return true;
|
|
}; |