Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="spinner"></div>
<button id="play">Play</button>
<button id="stop">Stop</button>


                .spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 70vmin;
  height: 70vmin;
  margin: -35vmin 0 0 -35vmin;
  border-radius: 50%;
  background: green;
.spinner::after {
  content: ">";
  position: absolute;
  left: 100%;
  top: 50%;
  margin-top: -10px;
  font-weight: bold;
  font-size: 3em;

body {
  overflow-y: hidden;


                let stopAt = 254,
    normalVelocity = 360, // degrees per second

InertiaPlugin.track(".spinner", "rotation");

function startSpin() {
  spinAnimation =".spinner", {
    rotation: "+=" + (normalVelocity * 1000), // go to a huge amount so that the velocity doesn't risk going negative on the repeat (360 back to 0)
    duration: 1000,
    repeat: -1,
    ease: "none"
  // ease up the timeScale
  gsap.fromTo(spinAnimation, {timeScale: 0}, {timeScale: 1, ease: "", duration: 1});

document.querySelector("#play").addEventListener("click", () => {

document.querySelector("#stop").addEventListener("click", () => {
  spinAnimation && spinAnimation.kill();
  let currentRotation = gsap.getProperty(".spinner", "rotation"),
      // do an unrestricted inertia tween to figure out where it'd naturally land first...
      naturalEndTween =".spinner", {inertia: {rotation: "auto", duration: "auto"}}).progress(1),
      endRotation = gsap.getProperty(".spinner", "rotation");
  naturalEndTween.progress(0).kill(); // revert the natural end tween, and then create the "real" one with the limit applied.
  spinAnimation =".spinner", {
    inertia: {
      rotation: {
        velocity: "auto",
        end: Math.floor(endRotation / 360) * 360 + stopAt
      duration: "auto"
    onComplete: () => gsap.set(".spinner", {rotation: stopAt}) // just to make sure that at the end, it's at the "real" stopAt (not the artificially large one for all the inertia stuff)