Merge pull request #3816 from NoelDeMartin/MOBILE-4362
MOBILE-4362: Fix Drag & Drop race conditionmain
commit
edf1aea478
|
@ -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<HTMLElement>('.ddarea') ??
|
||||
this.container,
|
||||
);
|
||||
|
||||
// All drag items have been created, position them.
|
||||
this.repositionDragsForQuestion();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue