diff --git a/src/addons/qtype/ddimageortext/classes/ddimageortext.ts b/src/addons/qtype/ddimageortext/classes/ddimageortext.ts index d02de988e..35ba19b53 100644 --- a/src/addons/qtype/ddimageortext/classes/ddimageortext.ts +++ b/src/addons/qtype/ddimageortext/classes/ddimageortext.ts @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CoreUtils } from '@services/utils/utils'; import { CoreDom } from '@singletons/dom'; import { CoreEventObserver } from '@singletons/events'; import { CoreLogger } from '@singletons/logger'; @@ -148,7 +147,10 @@ export class AddonQtypeDdImageOrTextQuestion { } } - await CoreUtils.nextTick(); + await CoreDom.waitToBeVisible( + this.container.querySelector('.ddarea') ?? + this.container, + ); // All drag items have been created, position them. this.repositionDragsForQuestion(); diff --git a/src/core/singletons/dom.ts b/src/core/singletons/dom.ts index a969e6463..eb3798944 100644 --- a/src/core/singletons/dom.ts +++ b/src/core/singletons/dom.ts @@ -123,8 +123,12 @@ export class CoreDom { * @returns True if element is visible inside the DOM. */ static isElementVisible(element: HTMLElement, checkSize = true): boolean { - if (checkSize && (element.clientWidth === 0 || element.clientHeight === 0)) { - return false; + if (checkSize) { + const dimensions = element.getBoundingClientRect(); + + if (dimensions.width === 0 || dimensions.height === 0) { + return false; + } } const style = getComputedStyle(element);