witchday/SceneTransition.js

26 lines
540 B
JavaScript
Raw Normal View History

2024-08-06 17:39:18 +00:00
class SceneTransition {
constructor() {
this.element = null;
}
createElement() {
this.element = document.createElement("div");
this.element.classList.add("SceneTransition");
}
fadeOut() {
this.element.classList.add("fade-out");
this.element.addEventListener("animationend", () => {
this.element.remove();
}, { once: true })
}
init(container, callback) {
this.createElement();
container.appendChild(this.element);
this.element.addEventListener("animationend", () => {
callback();
}, { once: true });
}
}