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
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
|
||||||
import { CoreDom } from '@singletons/dom';
|
import { CoreDom } from '@singletons/dom';
|
||||||
import { CoreEventObserver } from '@singletons/events';
|
import { CoreEventObserver } from '@singletons/events';
|
||||||
import { CoreLogger } from '@singletons/logger';
|
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.
|
// All drag items have been created, position them.
|
||||||
this.repositionDragsForQuestion();
|
this.repositionDragsForQuestion();
|
||||||
|
|
|
@ -123,9 +123,13 @@ export class CoreDom {
|
||||||
* @returns True if element is visible inside the DOM.
|
* @returns True if element is visible inside the DOM.
|
||||||
*/
|
*/
|
||||||
static isElementVisible(element: HTMLElement, checkSize = true): boolean {
|
static isElementVisible(element: HTMLElement, checkSize = true): boolean {
|
||||||
if (checkSize && (element.clientWidth === 0 || element.clientHeight === 0)) {
|
if (checkSize) {
|
||||||
|
const dimensions = element.getBoundingClientRect();
|
||||||
|
|
||||||
|
if (dimensions.width === 0 || dimensions.height === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const style = getComputedStyle(element);
|
const style = getComputedStyle(element);
|
||||||
if (style.opacity === '0' || style.display === 'none' || style.visibility === 'hidden') {
|
if (style.opacity === '0' || style.display === 'none' || style.visibility === 'hidden') {
|
||||||
|
|
Loading…
Reference in New Issue