<template>
  <transition appear name="custom-classes-transition" leave-active-class="animated fadeOut faster">
    <div
      v-if="show"
      class="scene-loading"
      :class="{ small: small, thumb: props.thumb }"
      @touchmove.prevent
    >
    <!-- :style="currentScene.icon && { backgroundImage: `url(${currentScene.icon})` }" -->

      <div class="ui-waiting">
        <div class="icon">
          <img :src="require('@/assets/images/loading.png')" alt="" />
        </div>
        <div class="txt">{{$t('common.loading')}}</div>
      </div>
    </div>
  </transition>
</template>
<script setup>
import { ref, watch, computed, onMounted, defineProps } from "vue";
import { useStore } from "vuex";
import { useApp } from "@/app";

const props = defineProps({
  small: {
    type: Boolean,
    default: false,
  },
  thumb: {
    type: Boolean,
    default: false,
  },
});
const store = useStore();

const show = ref(true);

const currentScene = computed(() => store.getters["scene/currentScene"]);

useApp().then((app) => {
  app.Scene.on("ready", () => {
    if (show.value) {
      show.value = false;
    }
  });
});
</script>
<style lang="scss" scoped>
.scene-loading {
  display: table;
  table-layout: fixed;
  height: 100%;
  width: 100%;
  z-index: 11;
  background-repeat: no-repeat;
  background-position: 50%;
  background-size: cover;
  .ui-waiting {
    color: #fff;
    text-align: center;
    display: table-cell;
    text-align: center;
    vertical-align: middle;
    width: 100%;
    height: 100%;
    .icon {
      width: 60px;
      height: 60px;
      position: relative;
      overflow: hidden;
      margin: 10px auto;
      > img {
        height: 60px;
        position: absolute;
        left: 0;
        top: 0;
        animation: loading 1s steps(15) infinite;
      }
    }
    .txt {
      font-size: 14px;
    }
    .spinner {
      width: 100%;
      text-align: center;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-top: 5px;
      > div {
        width: 5px;
        height: 5px;
        background-color: #fff;
        margin: 5px;
        border-radius: 100%;
        display: inline-block;
        animation: bouncedelay 1.4s infinite ease-in-out;
        animation-fill-mode: both;
      }

      .bounce1 {
        animation-delay: -0.32s;
      }
      .bounce2 {
        animation-delay: -0.16s;
      }
    }
  }
}
@keyframes loading {
  100% {
    left: -900px;
  }
}
</style>
