A simple breathing text animation.
A Pen by Tanner Dolby on CodePen.
A simple breathing text animation.
A Pen by Tanner Dolby on CodePen.
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>Breathe</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
<div class="author"> | |
<span class="char">b</span> | |
<span class="char">r</span> | |
<span class="char">e</span> | |
<span class="char">a</span> | |
<span class="char">t</span> | |
<span class="char">h</span> | |
<span class="char">e</span> | |
<span class="char" id="poof">!</span> | |
</div> | |
</body> | |
</html> |
const chars = document.querySelectorAll(".char"); | |
const headerName = document.querySelector(".author"); | |
let timeline = gsap.timeline(); | |
headerName.addEventListener("mouseover", () => { | |
timeline.from(chars, {opacity: 1, scale: 1, duration: 1, ease: "back"}) | |
.to(chars, { | |
"--font-weight": 900, | |
ease: "power", | |
duration: 0.5, | |
stagger: { | |
each: 0.1, | |
repeat: -1, | |
yoyo: true | |
} | |
}); | |
}); |
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.3.4/gsap.min.js"></script> |
@import url('https://fonts.googleapis.com/css2?family=Dosis&display=swap'); | |
@import url('https://fonts.googleapis.com/css2?family=Cairo&display=swap'); | |
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro&display=swap'); | |
@import url('https://fonts.googleapis.com/css2?family=Heebo:[email protected]&display=swap'); | |
$google-font-source-sans: "Source Sans Pro", sans-serif; | |
$google-font-cairo: "Cairo", sans-serif; | |
$google-font-dosis: "Dosis", sans-serif; | |
$google-font-heebo: "Heebo", sans-serif; | |
body { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
flex-direction: column; | |
margin: 0; | |
padding: 0; | |
min-height: 100vh; | |
background-color: #000 | |
} | |
.author { | |
display: flex; | |
font-family: $google-font-source-sans; | |
font-size: 4rem; | |
.char { | |
display: flex; | |
justify-content: space-around; | |
align-items: center; | |
font-family: $google-font-heebo; | |
font-variation-settings: "wght" var(--font-weight, 100); | |
color: #FFF; | |
} | |
#poof { | |
visibility: hidden; | |
} | |
} | |
.author:hover { | |
cursor: pointer; | |
} | |