From ce56d9dd2f20b6883150bf6f763493f45b87181b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 12 Jun 2024 11:17:10 +0200 Subject: [PATCH] MOBILE-4470 ddmarker: Fix regression caused by MOBILE-3403 --- src/addons/qtype/ddmarker/classes/ddmarker.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/addons/qtype/ddmarker/classes/ddmarker.ts b/src/addons/qtype/ddmarker/classes/ddmarker.ts index fead3a931..98d937316 100644 --- a/src/addons/qtype/ddmarker/classes/ddmarker.ts +++ b/src/addons/qtype/ddmarker/classes/ddmarker.ts @@ -20,6 +20,8 @@ import { CoreLogger } from '@singletons/logger'; import { AddonQtypeDdMarkerQuestionData } from '../component/ddmarker'; import { AddonQtypeDdMarkerGraphicsApi } from './graphics_api'; import { CoreUtils } from '@services/utils/utils'; +import { CoreDirectivesRegistry } from '@singletons/directives-registry'; +import { CoreExternalContentDirective } from '@directives/external-content'; /** * Class to make a question of ddmarker type work. @@ -678,7 +680,7 @@ export class AddonQtypeDdMarkerQuestion { /** * Wait for the background image to be loaded. */ - pollForImageLoad(): void { + async pollForImageLoad(): Promise { if (this.afterImageLoadDone) { // Already treated. return; @@ -689,6 +691,9 @@ export class AddonQtypeDdMarkerQuestion { return; } + // Wait for external-content to finish, otherwise the image doesn't have a src and the calculations are wrong. + await CoreDirectivesRegistry.waitDirectivesReady(bgImg, undefined, CoreExternalContentDirective); + if (!bgImg.src && this.imgSrc) { bgImg.src = this.imgSrc; }