$width: 160px;

.spin {
  width: $width;
  height: $width;
  border-radius: 100%;
  display: inline-block;
  position: relative;
  animation: spin-rotate 4s linear infinite;
  box-sizing: border-box;

  view {
    box-sizing: border-box;
    position: absolute;
  }

  .mask-left, .mask-right {
    // background: #fff;
    top: 0;
    width: calc(50% + 1px);
    height: 100%;
    overflow: hidden;
  }

  .mask-left {
    left: 0;

    .spin-bar {
      left: 100%;
      border-top-right-radius: $width;
      border-bottom-right-radius: $width;
      border-left: 0;
      // transform: rotate(180deg);
      transform-origin: center left;
      animation: spin-rotate-right 1.2s cubic-bezier(.25,.5,.25,1) 0.6s infinite, spin-color 2s linear infinite;
    }
  }

  .mask-right {
    right: 0;

    .spin-bar {
      left: -100%;
      border-top-left-radius: $width;
      border-bottom-left-radius: $width;
      border-right: 0;
      transform-origin: center right;
      animation: spin-rotate-right 1.2s cubic-bezier(1,.25,.5,.25) infinite, spin-color 2s linear infinite;
    }
  }

  .spin-bar {
    float: left;
    width: 100%;
    height: 100%;
    border-width: 4px;
    border-style: solid;
  }
}

@keyframes spin-rotate-right {
  0% {
    transform: rotate(0deg);
  }

  50% {
    transform: rotate(180deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes spin-rotate-left {
  0% {
    transform: rotate(180deg);
  }

  50% {
    transform: rotate(360deg);
  }

  100% {
    transform: rotate(540deg);
  }
}

@keyframes spin-rotate {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes spin-color {
  0%, 100% {
    border-color: #d62d20;
  }
  40% {
    border-color: #0057e7;
  }
  60% {
    border-color: #008744;
  }
  80%, 90% {
    border-color: #ffa700;
  }
}

.spin2box {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;
  text-align: center;
  background: rgba(255, 255, 255, .75);

  .spin2 {
    display: inline-block;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
}
