-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add typing effect for title name (#4)
- Loading branch information
1 parent
907d413
commit f86cc94
Showing
3 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var part = 0; | ||
var partIndex = 0; | ||
var content = [$('meta[name=author]').prop('content'), "@" + $('meta[name=github]').prop('content')]; | ||
var typingObj = document.querySelector("#typing"); | ||
var interval = setInterval(Typing, 100); | ||
|
||
function Typing() { | ||
var text = content[part].substring(0, partIndex + 1); | ||
typingObj.innerHTML = text; | ||
partIndex++; | ||
|
||
if(text === content[part]) { | ||
clearInterval(interval); | ||
setTimeout(function() { | ||
interval = setInterval(Delete, 50); | ||
}, 1000); | ||
} | ||
} | ||
|
||
function Delete() { | ||
var text = content[part].substring(0, partIndex - 1); | ||
typingObj.innerHTML = text; | ||
partIndex--; | ||
|
||
if (text === '') { | ||
clearInterval(interval); | ||
|
||
if(part == (content.length - 1)) | ||
part = 0; | ||
else | ||
part++; | ||
|
||
partIndex = 0; | ||
|
||
setTimeout(function() { | ||
interval = setInterval(Typing, 100); | ||
}, 200); | ||
} | ||
} |
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
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