Skip to content

Commit

Permalink
Merge pull request #1 from Runtus/interval-min-height
Browse files Browse the repository at this point in the history
fix: fix the inverted rect display
  • Loading branch information
iamzone authored Nov 2, 2023
2 parents 8efdee5 + 78419ee commit 8972daa
Showing 1 changed file with 9 additions and 3 deletions.
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

0 comments on commit 8972daa

Please sign in to comment.