<h1>GSAP Starter Template</h1>
<a hoverstagger="link" href="#" class="button w-inline-block">
  <div class="div-block-3">
    <div hoverstagger="text" id="title-a">Hello !</div>
    <div hoverstagger="text" class="text-block-3" id="title-aa">Hello !</div>
  </div>
</a>
@import url("https://fonts.googleapis.com/css?family=Signika+Negative:300,400&display=swap");
body {
  font-family: "Signika Negative", sans-serif;
  font-weight: 300;
}

.button {
  display: inline-block;
  opacity: 1;
  background-color: #2628b4;
  border-radius: 12px;
  padding: 16px 32px;
  font-weight: 700;
  color: white;
  text-decoration: none;
}

.div-block-3 {
  height: 20px;
  flex-direction: column;
  align-items: flex-start;
  display: flex;
  overflow: hidden;
}
console.clear(); // Start with a clean console on refesh
// //gsap.to()... infinity and beyond!

// //To learn more about using GreenSock's bonus plugins for free on CodePen visit: https://gsap.com/trial
gsap.registerPlugin(SplitText);
const btn = document.querySelector(".button");

var split = new SplitText("#title-a", { type: "chars" });
var splitb = new SplitText("#title-aa", { type: "chars" });
let isComplete = true;

const tl = gsap.timeline({
  // Create a timleine to control all the animations
  paused: true, // Set it to paused, because we want to .play() them at a specific moment
  onComplete: () => isComplete = true,
});

tl.fromTo(
  split.chars,
  {
    y: 0
  },
  {
    duration: 0.5,
    y: -20,
    stagger: 0.05
  }
);

tl.fromTo(
  splitb.chars,
  {
    y: 38
  },
  {
    duration: 0.5,
    y: -20,
    stagger: 0.05
  },
  "<" // Start tween at the same time as previous tween, check the docs for more info position parameter https://greensock.com/position-parameter
);

// Normal Javascript, add event listener to a specifc elment
btn.addEventListener("mouseenter", () => {
  if (!isComplete) return;
  isComplete = false;
  tl.restart();
});
btn.addEventListener("mouseleave", () => {
  if (!isComplete) return;
  isComplete = false;
  tl.restart();
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://unpkg.co/gsap@3/dist/gsap.min.js
  2. https://unpkg.com/gsap@3/dist/CSSRulePlugin.min.js
  3. https://assets.codepen.io/16327/CustomBounce3.min.js
  4. https://assets.codepen.io/16327/CustomEase3.min.js
  5. https://assets.codepen.io/16327/CustomWiggle3.min.js
  6. https://assets.codepen.io/16327/DrawSVGPlugin3.min.js
  7. https://unpkg.com/gsap@3/dist/Draggable.min.js
  8. https://unpkg.com/gsap@3/dist/EaselPlugin.min.js
  9. https://unpkg.com/gsap@3/dist/EasePack.min.js
  10. https://assets.codepen.io/16327/Flip.min.js
  11. https://assets.codepen.io/16327/GSDevTools3.min.js
  12. https://assets.codepen.io/16327/InertiaPlugin.min.js
  13. https://assets.codepen.io/16327/MorphSVGPlugin3.min.js
  14. https://unpkg.com/gsap@3/dist/MotionPathPlugin.min.js
  15. https://assets.codepen.io/16327/MotionPathHelper.min.js
  16. https://assets.codepen.io/16327/PhysicsPropsPlugin3.min.js
  17. https://assets.codepen.io/16327/Physics2DPlugin3.min.js
  18. https://unpkg.com/gsap@3/dist/PixiPlugin.min.js
  19. https://assets.codepen.io/16327/ScrambleTextPlugin3.min.js
  20. https://unpkg.com/gsap@3/dist/ScrollToPlugin.min.js
  21. https://unpkg.com/gsap@3/dist/ScrollTrigger.min.js
  22. https://assets.codepen.io/16327/SplitText3.min.js
  23. https://unpkg.com/gsap@3/dist/TextPlugin.min.js
  24. https://assets.codepen.io/16327/ScrollSmoother.min.js
  25. https://unpkg.com/gsap/dist/Observer.min.js