mirror of
https://github.com/imputnet/cobalt.git
synced 2025-01-19 13:18:28 +00:00
web/cutout: fix canvas visibility
This commit is contained in:
parent
28eb9ebe5d
commit
cc3e3be118
|
@ -12,7 +12,6 @@
|
|||
|
||||
let draggedOver = false;
|
||||
let file: File | undefined;
|
||||
let result: ImageBitmap;
|
||||
let imageContainer: HTMLElement;
|
||||
let canvas: HTMLCanvasElement;
|
||||
|
||||
|
@ -20,7 +19,7 @@
|
|||
|
||||
let worker: Worker;
|
||||
|
||||
const renderImageToCanvas = () => {
|
||||
const renderImageToCanvas = (result: ImageBitmap) => {
|
||||
if (canvas && result) {
|
||||
canvas.width = result.width;
|
||||
canvas.height = result.height;
|
||||
|
@ -40,8 +39,7 @@
|
|||
const eventData = event.data.cobaltRemoveBgWorker;
|
||||
if (eventData.result) {
|
||||
state = "done";
|
||||
result = eventData.result;
|
||||
renderImageToCanvas();
|
||||
renderImageToCanvas(eventData.result);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -53,7 +51,7 @@
|
|||
};
|
||||
|
||||
const exportImage = async () => {
|
||||
if (!result || !file) return;
|
||||
if (!file) return;
|
||||
|
||||
const resultBlob = await new Promise<Blob>((resolve, reject) => {
|
||||
canvas.toBlob(blob => {
|
||||
|
@ -110,7 +108,7 @@
|
|||
{/if}
|
||||
|
||||
{#if ["busy", "done"].includes(state)}
|
||||
<div id="image-preview" bind:this={imageContainer}>
|
||||
<div id="image-preview" bind:this={imageContainer} class={state}>
|
||||
{#if state === "busy"}
|
||||
<Skeleton width="100%" height="100%" class="big" />
|
||||
{/if}
|
||||
|
@ -175,6 +173,14 @@
|
|||
box-shadow: var(--button-box-shadow);
|
||||
}
|
||||
|
||||
#image-preview canvas {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#image-preview.done canvas {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.button-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
|
Loading…
Reference in a new issue