|
|
|
@ -22,6 +22,22 @@ export default class extends Controller { |
|
|
|
this.element.remove() |
|
|
|
} |
|
|
|
|
|
|
|
// The panel sits above the game frame rather than inside it, so the next
|
|
|
|
// screen renders behind it. Once it is there, the panel drops off the bottom
|
|
|
|
// and leaves the intro playing underneath.
|
|
|
|
leave() { |
|
|
|
if (this.leaving) return |
|
|
|
|
|
|
|
this.leaving = true |
|
|
|
document.addEventListener("turbo:frame-render", this.#slideAway, { once: true }) |
|
|
|
} |
|
|
|
|
|
|
|
#slideAway = async () => { |
|
|
|
this.element.classList.add("is-leaving") |
|
|
|
await this.#settle(this.element, "transitionend") |
|
|
|
this.close() |
|
|
|
} |
|
|
|
|
|
|
|
// The screen underneath may still be animating out. The wave is the last
|
|
|
|
// thing to leave, so waiting on it holds the modal until the exit is done.
|
|
|
|
async #openWhenSettled() { |
|
|
|
@ -89,7 +105,11 @@ export default class extends Controller { |
|
|
|
? parseFloat(style.animationDuration) + parseFloat(style.animationDelay) |
|
|
|
: parseFloat(style.transitionDuration) + parseFloat(style.transitionDelay) |
|
|
|
|
|
|
|
const finish = () => { |
|
|
|
// Descendants and ::backdrop send their own events up through the same
|
|
|
|
// element, and either would settle this early.
|
|
|
|
const finish = (event) => { |
|
|
|
if (event && (event.target !== element || event.pseudoElement)) return |
|
|
|
|
|
|
|
element.removeEventListener(eventName, finish) |
|
|
|
clearTimeout(timer) |
|
|
|
resolve() |
|
|
|
|