Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix the inverted rect display #1

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/shape/interval/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,18 @@ export function rect(
// Deal with width or height is negative.
const absX = width > 0 ? x : x + width;
const absY = height > 0 ? y : y + height;

// the diff between height and minHeight
const heightDiff = minHeight - height;
// when data is 0, minHeight get actions.

const isMinHeight = heightDiff > 0 && height === 0 ? true : false;
const absWidth = Math.abs(width);
const absHeight = Math.abs(height);
const absHeight = Math.abs(isMinHeight ? minHeight : height);
const finalX = absX + insetLeft;
const finalY = absY + insetTop;
const finalY = isMinHeight ? absY + insetTop - heightDiff : absY + insetTop;
const finalWidth = absWidth - (insetLeft + insetRight);
const finalHeight = absHeight - (insetTop + insetBottom) || minHeight;
const finalHeight = absHeight - (insetTop + insetBottom);

const clampWidth = tpShape
? finalWidth
Expand Down