Fix race when replacing views during fade
This commit is contained in:
parent
7ee735c2db
commit
371ed5a2b0
1 changed files with 9 additions and 5 deletions
14
script.js
14
script.js
|
|
@ -69,14 +69,18 @@
|
||||||
|
|
||||||
async function replace(view) {
|
async function replace(view) {
|
||||||
const el = ensureViewEl(view);
|
const el = ensureViewEl(view);
|
||||||
if (currentBase) {
|
const prev = currentBase;
|
||||||
await fadeOut(currentBase.el);
|
if (prev) {
|
||||||
$uxRoot.removeChild(currentBase.el);
|
const prevEl = prev.el;
|
||||||
if (typeof currentBase.view.destroy === 'function') currentBase.view.destroy();
|
if (prevEl && prevEl.isConnected) {
|
||||||
|
await fadeOut(prevEl);
|
||||||
|
if (prevEl.parentNode === $uxRoot) $uxRoot.removeChild(prevEl);
|
||||||
|
}
|
||||||
|
if (prev.view && typeof prev.view.destroy === 'function') prev.view.destroy();
|
||||||
}
|
}
|
||||||
$uxRoot.appendChild(el);
|
$uxRoot.appendChild(el);
|
||||||
await fadeIn(el);
|
|
||||||
currentBase = { view, el };
|
currentBase = { view, el };
|
||||||
|
await fadeIn(el);
|
||||||
if (typeof view.onShow === 'function') view.onShow();
|
if (typeof view.onShow === 'function') view.onShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue