Home:ALL Converter>CSS loader/Progress spinner Material angular 2+

CSS loader/Progress spinner Material angular 2+

Ask Time:2018-06-08T21:54:47         Author:Melchia

Json Formatter

I'm trying to imitate the loader/Progress spinner from angular material. So far I made the following component. But I don't know why the length of the dash isn't changing.

body {
  background-color: white;
}

// demo-specific
.showbox {
position: absolute;
   
}
// end demo-specific

.loader {
  position: relative;
  margin: 0 auto;
  width: 100px;
  &:before {
    content: '';
    display: block;
    padding-top: 100%;
  }
}

.circular {
  animation: rotate 2s linear infinite;
  height: 100%;
  transform-origin: center center;
  width: 100%;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
}

.path {
  stroke-dasharray: 1, 200;
  stroke-dashoffset: 0;
  animation: dash 2s ease-in-out infinite;
  stroke-linecap: round;
  stroke: #0057e7;
}

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

@keyframes dash {
  0% {
    stroke-dasharray: 20, 200;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 100, 200;
    stroke-dashoffset: -35px;
  }
  100% {
    stroke-dasharray: 200, 200;
    stroke-dashoffset: -125px;
  }
}
    <div class="showbox">
          <div class="loader">
            <svg class="circular" viewBox="25 25 50 50">
                <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/>
              </svg>
          </div>
        </div>

Author:Melchia,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50762238/css-loader-progress-spinner-material-angular-2
yy