Skip to content

Commit

Permalink
fix: remove extra spacing between 2 activity markers (#3052)
Browse files Browse the repository at this point in the history
When there are 2 markers, the center was translated/shifted too much. We
assume that the width value of markers is
`SHAPE_ACTIVITY_MARKER_ICON_SIZE`. We want to have a spacing value
between the 2 markers of `SHAPE_ACTIVITY_MARKER_ICON_MARGIN`.

To have 2 markers horizontally centered and closed to each other, we
need to translate the first marker to the left and the second to the
right by half the value of the marker width. To add a space between the
2 markers, we need to translate both markers by half the value of the
global "spacing value". Previously, the translation value included the
full marker width which is too much.

Also include refactoring:
- Use more accurate name for the parameters of
`getMarkerIconOriginFunction`.
  • Loading branch information
tbouffard committed Mar 7, 2024
1 parent 6886a6b commit c0c50aa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/component/mxgraph/shape/activity-shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ import { getBpmnIsInstantiating } from '../style/utils';
import { buildPaintParameter } from './render/icon-painter';
import { orderActivityMarkers } from './render/utils';

function getMarkerIconOriginFunction(allMarkers: number, markerOrder: number): (canvas: BpmnCanvas) => void {
return allMarkers === 1
function getMarkerIconOriginFunction(numberOfMarkers: number, markerPosition: number): (canvas: BpmnCanvas) => void {
return numberOfMarkers === 1
? (canvas: BpmnCanvas) => canvas.setIconOriginForIconBottomCentered()
: (canvas: BpmnCanvas) => {
// Here we suppose that we have 'allMarkers === 2'
// Here we suppose that we have 'numberOfMarkers === 2'
// More markers will be supported when implementing adhoc subprocess or compensation marker
canvas.setIconOriginForIconBottomCentered();
const xTranslation = Math.pow(-1, markerOrder) * (StyleDefault.SHAPE_ACTIVITY_MARKER_ICON_SIZE / 2 + StyleDefault.SHAPE_ACTIVITY_MARKER_ICON_MARGIN);
const xTranslation = (Math.pow(-1, markerPosition) * (StyleDefault.SHAPE_ACTIVITY_MARKER_ICON_SIZE + StyleDefault.SHAPE_ACTIVITY_MARKER_ICON_MARGIN)) / 2;
canvas.translateIconOrigin(xTranslation, 0);
};
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c0c50aa

Please sign in to comment.