Skip to content

Commit

Permalink
simplify implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
tbouffard committed Mar 4, 2024
1 parent ce3a1fe commit 9c4e975
Showing 1 changed file 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 @@ -27,15 +27,15 @@ import { orderActivityMarkers } from './render/utils';

function getMarkerIconOriginFunction(numberOfMarkers: number, markerPosition: number): (canvas: BpmnCanvas) => void {
// work for 1, 2, 3 and 4 markers
const middleValue = (numberOfMarkers + 1) / 2;
if (markerPosition == middleValue) {

// middle marker
if (markerPosition == (numberOfMarkers + 1) / 2) {
return (canvas: BpmnCanvas) => canvas.setIconOriginForIconBottomCentered();
}

const translationFactor = 2 * markerPosition - (numberOfMarkers + 1);
return (canvas: BpmnCanvas) => {
canvas.setIconOriginForIconBottomCentered();
const xTranslation = translationFactor * (StyleDefault.SHAPE_ACTIVITY_MARKER_ICON_SIZE + StyleDefault.SHAPE_ACTIVITY_MARKER_ICON_MARGIN) / 2;
const xTranslation = ((2 * markerPosition - (numberOfMarkers + 1)) * (StyleDefault.SHAPE_ACTIVITY_MARKER_ICON_SIZE + StyleDefault.SHAPE_ACTIVITY_MARKER_ICON_MARGIN)) / 2;
canvas.translateIconOrigin(xTranslation, 0);
};
}
Expand Down

0 comments on commit 9c4e975

Please sign in to comment.