Skip to content

Commit

Permalink
#5107 - fixed tail incorrect top\bottom distance detection
Browse files Browse the repository at this point in the history
  • Loading branch information
daniil-sloboda committed Aug 23, 2024
1 parent 667e756 commit d13decc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/ketcher-core/src/domain/entities/multitailArrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ export class MultitailArrow extends BaseMicromoleculeEntity {
if (typeof second === 'number') {
const originalValue = this.tailsYOffset.get(second) as number;
let updatedHeight = Math.max(
MultitailArrow.MIN_TOP_BOTTOM_OFFSET,
MultitailArrow.MIN_TAIL_DISTANCE,
Math.min(
originalValue + offset,
this.height - MultitailArrow.MIN_TOP_BOTTOM_OFFSET,
this.height - MultitailArrow.MIN_TAIL_DISTANCE,
),
);
if (normalize) {
Expand Down
32 changes: 21 additions & 11 deletions packages/ketcher-react/src/script/editor/tool/arrow/commonArrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export class CommonArrowTool extends ArrowTool implements Tool {
return dragContext.closestItem.map === MULTITAIL_ARROW_KEY;
}

static isDragContextReaction(
dragContext: CommonArrowDragContext<
MultitailArrowClosestItem | ReactionArrowClosestItem
>,
): dragContext is CommonArrowDragContext<ReactionArrowClosestItem> {
return dragContext.closestItem.map === 'rxnArrows';
}

private dragContext:
| CommonArrowDragContext<
MultitailArrowClosestItem | ReactionArrowClosestItem
Expand Down Expand Up @@ -101,13 +109,15 @@ export class CommonArrowTool extends ArrowTool implements Tool {
event,
this.dragContext,
);
} else {
// Otherwise build fails during prod build but not dev
const dragContext = this
.dragContext as CommonArrowDragContext<ReactionArrowClosestItem>;
dragContext.action = this.reactionMoveTool.mousemove(event, dragContext);
} else if (CommonArrowTool.isDragContextReaction(this.dragContext)) {
this.dragContext.action = this.reactionMoveTool.mousemove(
event,
this.dragContext,
);
}
if (this.dragContext.action) {
this.editor.update(this.dragContext.action, true);
}
this.editor.update(this.dragContext.action, true);
}

mouseup(event: PointerEvent) {
Expand All @@ -121,11 +131,11 @@ export class CommonArrowTool extends ArrowTool implements Tool {
event,
this.dragContext,
);
} else {
// Otherwise build fails during prod build but not dev
const dragContext = this
.dragContext as CommonArrowDragContext<ReactionArrowClosestItem>;
dragContext.action = this.reactionMoveTool.mouseup(event, dragContext);
} else if (CommonArrowTool.isDragContextReaction(this.dragContext)) {
this.dragContext.action = this.reactionMoveTool.mouseup(
event,
this.dragContext,
);
}
const { action } = this.dragContext;
if (action) {
Expand Down

0 comments on commit d13decc

Please sign in to comment.