1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2024-11-10 11:35:52 +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, zoom: Zoom,
renderConfig: StaticCanvasRenderConfig, renderConfig: StaticCanvasRenderConfig,
appState: StaticCanvasAppState, appState: StaticCanvasAppState,
): ExcalidrawElementWithCanvas => { ): ExcalidrawElementWithCanvas | null => {
const canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
const context = canvas.getContext("2d")!; const context = canvas.getContext("2d")!;
const padding = getCanvasPadding(element); const padding = getCanvasPadding(element);
@ -210,6 +210,10 @@ const generateElementCanvas = (
zoom, zoom,
); );
if (!width || !height) {
return null;
}
canvas.width = width; canvas.width = width;
canvas.height = height; canvas.height = height;
@ -540,6 +544,10 @@ const generateElementWithCanvas = (
appState, appState,
); );
if (!elementWithCanvas) {
return null;
}
elementWithCanvasCache.set(element, elementWithCanvas); elementWithCanvasCache.set(element, elementWithCanvas);
return elementWithCanvas; return elementWithCanvas;
@ -742,6 +750,10 @@ export const renderElement = (
renderConfig, renderConfig,
appState, appState,
); );
if (!elementWithCanvas) {
return;
}
drawElementFromCanvas( drawElementFromCanvas(
elementWithCanvas, elementWithCanvas,
context, context,
@ -881,6 +893,10 @@ export const renderElement = (
appState, appState,
); );
if (!elementWithCanvas) {
return;
}
const currentImageSmoothingStatus = context.imageSmoothingEnabled; const currentImageSmoothingStatus = context.imageSmoothingEnabled;
if ( if (