Skip to content

Instantly share code, notes, and snippets.

@moelle89
Created August 21, 2023 12:13
Show Gist options
  • Save moelle89/8dd36f1898153bdeff6ef5bf7d9be8dc to your computer and use it in GitHub Desktop.
Save moelle89/8dd36f1898153bdeff6ef5bf7d9be8dc to your computer and use it in GitHub Desktop.
Learn GSAP text effect 01
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap" rel="stylesheet">
<div class="container">
<p>The race for the presidency is usually decided in a small number of key battleground states that switch party allegiance between elections.</p>
</div>
let split
let animation = gsap.timeline({id:"animation", repeat:10, repeatDelay:1})
function init(){
split = new SplitText("p", {type:"lines"})
gsap.set(".container", {autoAlpha:1})
animation.from(split.lines, {opacity:0, rotationX:-20, rotationY:0, stagger:0.2, transformOrigin:"50% 50% -100"})
}
window.addEventListener("load", init)
<script src="https://unpkg.co/gsap@3/dist/gsap.min.js"></script>
<script src="https://assets.codepen.io/16327/SplitText3.min.js"></script>
<script src="https://unpkg.com/gsap@3/dist/TextPlugin.min.js"></script>
<script src="https://unpkg.com/gsap@3/dist/EasePack.min.js"></script>
html, body {
width:100vw;
height:100vh;
font-family:'Montserrat', sans-serif;
color: #fff;
background: #1a1a1a;
margin: 0;
}
body {
display: flex;
justify-content: center;
overflow: hidden;
align-items: center;
}
.container {
height: 100%;
display: flex;
align-items: center;
width: 500px;
visibility: hidden;
perspective: 900px;
}
p {
font-size: 36px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment