<link href='//fonts.googleapis.com/css?family=Signika+Negative:300,400' rel='stylesheet' type='text/css'>
<div class="box green"></div>
<div class="nav">
    <button id="restart">play again</button>

    <button id="invalidate">invalidate and play again</button>

  
/* Global styles come from external css https://codepen.io/GreenSock/pen/JGaKdQ*/


body {
  margin:10px;
}

button {
  display:inline;
}
var t = gsap.to(".green", {duration: 1, x: "+=100"});

document.querySelector("#restart").addEventListener("click", function() {
  t.restart();
});

document.querySelector("#invalidate").addEventListener("click", function() {
  t.invalidate();
  t.restart();
});

External CSS

  1. https://codepen.io/GreenSock/pen/JGaKdQ

External JavaScript

  1. https://cdn.jsdelivr.net/npm/gsap@3.0.1/dist/gsap.min.js