Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions src/components/Calendar/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const Grid = forwardRef<HTMLDivElement, GridProps>(function Grid(

const handleResize = useCallback(
(ctx: CanvasRenderingContext2D) => {
ctx.canvas.width = window.innerWidth * screenWidthMultiplier;
const canvasWidth = window.innerWidth * screenWidthMultiplier;

ctx.canvas.width = canvasWidth * window.devicePixelRatio;
ctx.canvas.style.width = canvasWidth + "px";

drawGrid(ctx, zoom, rows, cols, startDate);
},
[cols, startDate, rows, zoom]
Expand All @@ -41,8 +45,10 @@ const Grid = forwardRef<HTMLDivElement, GridProps>(function Grid(
canvas.style.letterSpacing = "1px";
const ctx = canvas.getContext("2d");
if (!ctx) return;
const canvasHeight = rows * boxHeight + 1;

ctx.canvas.height = rows * boxHeight + 1;
ctx.canvas.height = canvasHeight * window.devicePixelRatio;
ctx.canvas.style.height = canvasHeight + "px";

handleResize(ctx);
}, [date, rows, zoom, handleResize]);
Expand Down
10 changes: 8 additions & 2 deletions src/components/Calendar/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ const Header: FC<HeaderProps> = ({ zoom, topBarWidth }) => {

const handleResize = useCallback(
(ctx: CanvasRenderingContext2D) => {
ctx.canvas.width = window.innerWidth * screenWidthMultiplier;
ctx.canvas.height = headerHeight + 1;
const canvasWidth = window.innerWidth * screenWidthMultiplier;
const canvasHeight = headerHeight + 1;

ctx.canvas.width = canvasWidth * window.devicePixelRatio;
ctx.canvas.height = canvasHeight * window.devicePixelRatio;
ctx.canvas.style.width = canvasWidth + "px";
ctx.canvas.style.height = canvasHeight + "px";
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);

drawHeader(ctx, zoom, cols, startDate, week, dayOfYear);
},
Expand Down
2 changes: 2 additions & 0 deletions src/utils/drawGrid/drawGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const drawGrid = (
parsedStartDate: Day
) => {
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
ctx.scale(window.devicePixelRatio, window.devicePixelRatio);

const canvasWrapper = document.getElementById(canvasWrapperId);
if (!canvasWrapper) return;

Expand Down