diff options
author | JinweiClarkChao <[email protected]> | 2015-08-25 23:36:32 +0800 |
---|---|---|
committer | JinweiClarkChao <[email protected]> | 2015-08-26 08:44:45 +0800 |
commit | 0f5825e65a9beba4ebb82ff7827d7030fb79fd9c (patch) | |
tree | ad82db9bcfc54d00a52437fb5b6b00b9f27d8761 /js/portfolio.js | |
parent | f8bfa21feb6a7b66959e76e1d06c870bdfdff98a (diff) | |
download | ring0.xyz-0f5825e65a9beba4ebb82ff7827d7030fb79fd9c.tar.gz |
fork https://jessfraz.com/
Diffstat (limited to 'js/portfolio.js')
-rw-r--r-- | js/portfolio.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/js/portfolio.js b/js/portfolio.js new file mode 100644 index 0000000..6feeeae --- /dev/null +++ b/js/portfolio.js | |||
@@ -0,0 +1,26 @@ | |||
1 | var sleep = function(ms, callback) { | ||
2 | setTimeout(function() { | ||
3 | callback() | ||
4 | }, ms) | ||
5 | }, | ||
6 | favthings = ["Python", "C programming", "raspberrypi", "Linux"], | ||
7 | removeClass = function(el, className) { | ||
8 | el.classList ? el.classList.remove(className) : el.className = el.className.replace(new RegExp("(^|\\b)" + className.split(" ").join("|") + "(\\b|$)", "gi"), " ") | ||
9 | }, | ||
10 | addClass = function(el, className) { | ||
11 | el.classList ? el.classList.add(className) : el.className += " " + className | ||
12 | }, | ||
13 | i = 0, | ||
14 | nextThing = function(thing) { | ||
15 | i < favthings.length - 1 ? i++ : i = 0, removeClass(thing, "slideInDown"), addClass(thing, "slideOutUp"), sleep(700, function() { | ||
16 | thing.innerHTML = favthings[i], removeClass(thing, "slideOutUp"), addClass(thing, "slideInDown") | ||
17 | }) | ||
18 | }; | ||
19 | document.addEventListener("DOMContentLoaded", function() { | ||
20 | var thing = document.querySelectorAll(".favthing")[0]; | ||
21 | setTimeout(function() { | ||
22 | nextThing(thing) | ||
23 | }, 1e3), setInterval(function() { | ||
24 | nextThing(thing) | ||
25 | }, 4e3) | ||
26 | }); | ||