<template>
  <div>
    <div v-if="type === 'circle'" class="lds-default" :class="{'lds-whitebg':iswhitebg}">
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
      <div></div>
    </div>
    <div v-else-if="type === 'sound'" class="spinner">
      <div class="rect1"></div>
      <div class="rect2"></div>
      <div class="rect3"></div>
      <div class="rect4"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'courseLoading',
  props: {
    iswhitebg: {
      type: Boolean,
      default: false
    },
    type: {
      type: String,
      default: 'sound'
    }
  }
};
</script>

<style scoped>
@keyframes lds-default {
  0%,
  20%,
  80%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.5);
  }
}
.lds-default {
  display: inline-block;
  position: relative;
  width: 64px;
  height: 64px;
}
.lds-default div {
  position: absolute;
  width: 5px;
  height: 5px;
  background: #b2b2b2;
  border-radius: 50%;
  animation: lds-default 1.2s linear infinite;
}
.lds-whitebg div{
  background: #fff;
}
.lds-default div:nth-child(1) {
  animation-delay: 0s;
  top: 29px;
  left: 53px;
}
.lds-default div:nth-child(2) {
  animation-delay: -0.1s;
  top: 18px;
  left: 50px;
}
.lds-default div:nth-child(3) {
  animation-delay: -0.2s;
  top: 9px;
  left: 41px;
}
.lds-default div:nth-child(4) {
  animation-delay: -0.3s;
  top: 6px;
  left: 29px;
}
.lds-default div:nth-child(5) {
  animation-delay: -0.4s;
  top: 9px;
  left: 18px;
}
.lds-default div:nth-child(6) {
  animation-delay: -0.5s;
  top: 18px;
  left: 9px;
}
.lds-default div:nth-child(7) {
  animation-delay: -0.6s;
  top: 29px;
  left: 6px;
}
.lds-default div:nth-child(8) {
  animation-delay: -0.7s;
  top: 41px;
  left: 9px;
}
.lds-default div:nth-child(9) {
  animation-delay: -0.8s;
  top: 50px;
  left: 18px;
}
.lds-default div:nth-child(10) {
  animation-delay: -0.9s;
  top: 53px;
  left: 29px;
}
.lds-default div:nth-child(11) {
  animation-delay: -1s;
  top: 50px;
  left: 41px;
}
.lds-default div:nth-child(12) {
  animation-delay: -1.1s;
  top: 41px;
  left: 50px;
}

@keyframes sk-stretchdelay {
  0%, 40%, 100% {
    transform: scaleY(0.3);
  }  20% {
    transform: scaleY(1.0);
  }
}

.spinner {
  margin: 0.48rem auto;
  width: 0.64rem;
  height: 0.56rem;
  display: flex;
  justify-content: space-around;
}

.spinner > div {
  background-color: #eeeeee;
  height: 100%;
  width: 0.08rem;
  display: inline-block;
  animation: sk-stretchdelay 1.5s infinite ease-in-out;
  border-radius: 0.04rem;
}

.spinner .rect2 {
  animation-delay: -1.3s;
}

.spinner .rect3 {
  animation-delay: -1.2s;
}

.spinner .rect4 {
  animation-delay: -1.1s;
}
</style>
