Fixes meme creator, whoops
This commit is contained in:
parent
f46c4753a9
commit
1e00b7680c
1 changed files with 6 additions and 6 deletions
|
@ -21,14 +21,14 @@ document.querySelector("body").addEventListener("click", event => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
event.explicitOriginalTarget.classList &&
|
event.target.classList &&
|
||||||
event.explicitOriginalTarget.classList[0] === "playground__content__meme__canvas__thumbnail"
|
event.target.classList[0] === "playground__content__meme__canvas__thumbnail"
|
||||||
) {
|
) {
|
||||||
for (const thumbnail of document.querySelectorAll(".playground__content__meme__canvas__thumbnail"))
|
for (const thumbnail of document.querySelectorAll(".playground__content__meme__canvas__thumbnail"))
|
||||||
thumbnail.classList.remove("selected");
|
thumbnail.classList.remove("selected");
|
||||||
|
|
||||||
event.explicitOriginalTarget.classList.add("selected");
|
event.target.classList.add("selected");
|
||||||
updateCanvas(event.explicitOriginalTarget);
|
updateCanvas(event.target);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -377,10 +377,10 @@ function updateCanvas(imageSource) {
|
||||||
clearCanvas(canvas);
|
clearCanvas(canvas);
|
||||||
|
|
||||||
if (imageSource) {
|
if (imageSource) {
|
||||||
ctx.drawImage(imageSource, 0, 0, canvasWidth, 600 * imageSource.height / imageSource.width);
|
ctx.drawImage(imageSource, 0, 0, canvasWidth, canvasHeight);
|
||||||
img.src = imageSource.src;
|
img.src = imageSource.src;
|
||||||
} else {
|
} else {
|
||||||
ctx.drawImage(imageSource, 0, 0, canvasWidth, 600 * imageSource.height / imageSource.width);
|
ctx.drawImage(img, 0, 0, canvasWidth, canvasHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
positionCanvasText(ctx, canvasHeight, canvasWidth);
|
positionCanvasText(ctx, canvasHeight, canvasWidth);
|
||||||
|
|
Loading…
Reference in a new issue