A Pen by Pustak Pathak on CodePen.
Created
March 31, 2023 07:44
-
-
Save PustakP/3a1d0c07e6b5bec3a4805cc3a4fb8219 to your computer and use it in GitHub Desktop.
Hacked Text Effect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1 data-value="PUSTAK PATHAK">PUSTAK PATHAK</h1> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
let interval = null; | |
document.querySelector("h1").onmouseover = event => { | |
let iteration = 0; | |
clearInterval(interval); | |
interval = setInterval(() => { | |
event.target.innerText = event.target.innerText | |
.split("") | |
.map((letter, index) => { | |
if(index < iteration) { | |
return event.target.dataset.value[index]; | |
} | |
return letters[Math.floor(Math.random() * 26)] | |
}) | |
.join(""); | |
if(iteration >= event.target.dataset.value.length){ | |
clearInterval(interval); | |
} | |
iteration += 1 / 3; | |
}, 50); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://codepen.io/Hyperplexed/pen/xxYJYjM/54407644e24173ad6019b766443bf2a6.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
display: grid; | |
place-items: center; | |
height: 100vh; | |
background-color: black; | |
margin: 0rem; | |
overflow: hidden; | |
} | |
h1 { | |
font-family: 'Space Mono', monospace; | |
font-size: clamp(3rem, 10vw, 10rem); | |
color: white; | |
padding: 0rem clamp(1rem, 2vw, 3rem); | |
border-radius: clamp(0.4rem, 0.75vw, 1rem); | |
} | |
h1:hover { | |
background-color: white; | |
color: black; | |
} | |
a:link { text-decoration: none; } | |
a:visited { text-decoration: none; } | |
a:hover { text-decoration: none; } | |
a:active { text-decoration: none; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment