loading-screen.js 819 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { types } from "assets/types.js";
  2. class loading_screen {
  3. #cover;
  4. static #self;
  5. constructor(cover = undefined) {
  6. if (loading_screen.#self instanceof loading_screen) {
  7. return loading_screen.#self;
  8. }
  9. loading_screen.#self = this;
  10. types.check_html_element(cover);
  11. this.#cover = cover;
  12. this.#prepare();
  13. }
  14. get cover() {
  15. return this.#cover;
  16. }
  17. #prepare() {
  18. this.cover.style.transition = "opacity 0.5s ease-in-out";
  19. }
  20. show() {
  21. this.cover.style.display = "";
  22. this.cover.style.opacity = "1";
  23. }
  24. hide() {
  25. this.cover.style.opacity = "0";
  26. setTimeout(() => {
  27. this.cover.style.display = "none";
  28. }, 500);
  29. }
  30. }
  31. export { loading_screen };