Fix image occlusion flicker caused by setupI18n() (#3253)

This commit is contained in:
Abdo 2024-06-24 10:48:49 +03:00 committed by GitHub
parent 930c97b1c7
commit 4221e54390
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -44,11 +44,6 @@ interface SetupImageOcclusionOptions {
async function setupImageOcclusion(setupOptions?: SetupImageOcclusionOptions): Promise<void> {
await waitForImage();
await setupI18n({
modules: [
ModuleName.NOTETYPES,
],
});
window.addEventListener("load", () => {
window.addEventListener("resize", () => setupImageOcclusion(setupOptions));
});
@ -120,7 +115,7 @@ function calculateContainerSize(
let oneTimeSetupDone = false;
function setupImageOcclusionInner(setupOptions?: SetupImageOcclusionOptions): void {
async function setupImageOcclusionInner(setupOptions?: SetupImageOcclusionOptions): Promise<void> {
const canvas = document.querySelector(
"#image-occlusion-canvas",
) as HTMLCanvasElement | null;
@ -135,6 +130,11 @@ function setupImageOcclusionInner(setupOptions?: SetupImageOcclusionOptions): vo
"#image-occlusion-container img",
) as HTMLImageElement;
if (image == null) {
await setupI18n({
modules: [
ModuleName.NOTETYPES,
],
});
container.innerText = tr.notetypeErrorNoImageToShow();
return;
}