Skip to content

Commit

Permalink
Clip Suspense diamonds so they don't overflow after being resized
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed Jul 30, 2021
1 parent b7e66ec commit 9c656f2
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,26 @@ export class SuspenseEventsView extends View {
return; // Not in view
}

const drawableRect = intersectionOfRects(suspenseRect, rect);

// Clip diamonds so they don't overflow if the view has been resized (smaller).
const region = new Path2D();
region.rect(
drawableRect.origin.x,
drawableRect.origin.y,
drawableRect.size.width,
drawableRect.size.height,
);
context.save();
context.clip(region);
context.beginPath();
context.fillStyle = fillStyle;
context.moveTo(xStart, y - halfSize);
context.lineTo(xStart + halfSize, y);
context.lineTo(xStart, y + halfSize);
context.lineTo(xStart - halfSize, y);
context.fill();
context.restore();
} else {
const xStop = timestampToPosition(
timestamp + duration,
Expand Down

0 comments on commit 9c656f2

Please sign in to comment.