<div class="bar gradient-green"></div>
.bar {
  width: 100%;
  height: 50px;
  opacity: 0;
}
console.clear();

const tl = gsap
  .timeline({
    repeat: -1,
    repeatDelay: 1,
    paused: true,
    defaults: {
      ease: "power1.inOut",
      duration: 1
    }
  })
  .from(".bar", {
    scaleX: 0,
    transformOrigin: "center left"
  })
  .to(
    ".bar",
    {
      scaleX: 0,
      transformOrigin: "center right"
    },
    "+=1"
  );

gsap.set(".bar", { opacity: 1 });
tl.play();

External CSS

  1. https://codepen.io/GreenSock/pen/xxmzBrw.css

External JavaScript

  1. https://unpkg.com/gsap@3/dist/gsap.min.js