Created
November 1, 2018 16:21
-
-
Save jamesgeorge007/0394d94b5224863bd6371e704c1901f3 to your computer and use it in GitHub Desktop.
Typed-Animation using vanilla-JS demonstrating DOM manipulation.
This file contains 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
<!DOCTYPE html> | |
<html lang="en" dir="ltr"> | |
<head> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="style.css"> | |
<title>Typed Anim</title> | |
</head> | |
<body> | |
<script src="main.js"></script> | |
</body> | |
</html> |
This file contains 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
let i = 0, j = 0; | |
let bio = ['Full Stack Developer', 'Android & i-os Developer', 'Desktop App Developer', 'Open source contributor']; | |
window.onload = () => animateText(); | |
let heading = document.createElement('h1'); | |
heading.style = 'text-align: center;font-size: 3.2em;font-family: algerian;margin-top: 30vh;' | |
document.querySelector('body').appendChild(heading); | |
let animateText = () => { | |
if(i < bio[j].length){ | |
heading.innerHTML += bio[j].charAt(i); | |
i++; | |
setTimeout(animateText, 120); | |
} else{ | |
heading.innerHTML = ''; | |
i = 0; | |
if(j < bio.length-1){ | |
j++; | |
} else{ | |
j = 0; | |
} | |
animateText(); | |
} | |
} |
This file contains 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
*{ | |
padding: 0px; | |
outline: none; | |
margin: 0px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment