Skip to content

Instantly share code, notes, and snippets.

@tnylea
Created November 17, 2022 21:24
Show Gist options
  • Save tnylea/dced62f0aad95372f793b08ef56824f9 to your computer and use it in GitHub Desktop.
Save tnylea/dced62f0aad95372f793b08ef56824f9 to your computer and use it in GitHub Desktop.
simple text reveal animation with GSAP
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TailwindCSS Text Reveal Animation</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.3/gsap.min.js"></script>
<script src="https://unpkg.com/split-type"></script>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div class="w-screen h-screen flex items-center justify-center">
<h1 id="text" class="text-8xl font-bold" style="clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);">Awesome Sauce 🤘</h1>
</div>
<script>
let text = new SplitType('#text');
let characters = document.querySelectorAll('.char');
for(i=0; i<characters.length; i++){
characters[i].classList.add('translate-y-full');
}
let tween = gsap.to('.char', {
y: 0,
stagger: 0.05,
delay: 0.2,
duration: .5
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment