1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2024-11-02 03:25:53 +01:00

fix: drawing from 0-dimension canvas (#8356)

This commit is contained in:
David Luzar 2024-08-09 21:36:04 +02:00 committed by GitHub
parent 87a9430809
commit 88014ace4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -199,7 +199,7 @@ const generateElementCanvas = (
zoom: Zoom,
renderConfig: StaticCanvasRenderConfig,
appState: StaticCanvasAppState,
): ExcalidrawElementWithCanvas => {
): ExcalidrawElementWithCanvas | null => {
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d")!;
const padding = getCanvasPadding(element);
@ -210,6 +210,10 @@ const generateElementCanvas = (
zoom,
);
if (!width || !height) {
return null;
}
canvas.width = width;
canvas.height = height;
@ -540,6 +544,10 @@ const generateElementWithCanvas = (
appState,
);
if (!elementWithCanvas) {
return null;
}
elementWithCanvasCache.set(element, elementWithCanvas);
return elementWithCanvas;
@ -742,6 +750,10 @@ export const renderElement = (
renderConfig,
appState,
);
if (!elementWithCanvas) {
return;
}
drawElementFromCanvas(
elementWithCanvas,
context,
@ -881,6 +893,10 @@ export const renderElement = (
appState,
);
if (!elementWithCanvas) {
return;
}
const currentImageSmoothingStatus = context.imageSmoothingEnabled;
if (