summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinweiClarkChao <[email protected]>2015-08-25 23:36:32 +0800
committerJinweiClarkChao <[email protected]>2015-08-26 08:44:45 +0800
commit0f5825e65a9beba4ebb82ff7827d7030fb79fd9c (patch)
treead82db9bcfc54d00a52437fb5b6b00b9f27d8761 /js/portfolio.js
parentf8bfa21feb6a7b66959e76e1d06c870bdfdff98a (diff)
downloadring0.xyz-0f5825e65a9beba4ebb82ff7827d7030fb79fd9c.tar.gz
fork https://jessfraz.com/
Diffstat (limited to 'js/portfolio.js')
-rw-r--r--js/portfolio.js26
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 @@
1var 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 };
19document.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});
Powered by cgit v1.2.3 (git 2.41.0)