Skip to content

Instantly share code, notes, and snippets.

@jamesgeorge007
Created November 1, 2018 16:21
Show Gist options
  • Save jamesgeorge007/0394d94b5224863bd6371e704c1901f3 to your computer and use it in GitHub Desktop.
Save jamesgeorge007/0394d94b5224863bd6371e704c1901f3 to your computer and use it in GitHub Desktop.
Typed-Animation using vanilla-JS demonstrating DOM manipulation.
<!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>
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();
}
}
*{
padding: 0px;
outline: none;
margin: 0px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment