X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=docs%2Fv0.2%2Findex.js;fp=docs%2Fv0.2%2Findex.js;h=e9b65c1180058942b54995bc7e3606c017143a2f;hb=3787f011144279a73401b7709676058508735e0e;hp=0000000000000000000000000000000000000000;hpb=717c399364f77f606c1e07d515127ece31ccb878;p=awesomized%2Fext-ion diff --git a/docs/v0.2/index.js b/docs/v0.2/index.js new file mode 100644 index 0000000..e9b65c1 --- /dev/null +++ b/docs/v0.2/index.js @@ -0,0 +1,49 @@ +"use strict"; + +document.addEventListener("DOMContentLoaded", function() { + const doTransition = function(e, trans, state, speed) { + e.classList.remove(trans + "-in", trans + "-out", "trans-slow", "trans-fast"); + e.classList.add(trans + "-" + state, "trans-" + speed); + return (cb) => setTimeout(cb, speed === "slow" ? 600 : 200); + }; + const letElementBlink = function(e, last) { + setTimeout(() => doTransition(e, "fade", "out", "fast")(function() { + e.classList.add("blink"); + doTransition(e, "fade", "in", "fast")(function() { + e.classList.remove("blink"); + doTransition(e, "fade", "out", "slow")(function () { + doTransition(e, "fade", "in", "slow"); + }); + }); + }), 200); + }; + const onHashChange = function() { + if (location.hash.length > 1) { + let hash = decodeURIComponent(location.hash.substring(1)); + let e = document.getElementById(hash) || document.getElementById(location.hash.substring(1)); + if (e) { + letElementBlink(e); + } else { + if (hash.substring(hash.length-1) === "*") { + hash = hash.substring(0, hash.length-1); + } + let klass = (hash.substring(0,1) === "$") ? "var" : "constant"; + let scrolled = false; + Array.prototype.forEach.call(document.getElementsByClassName(klass), function(e) { + if (e.textContent.substring(0, hash.length) !== hash) { + return; + } + if (!scrolled) { + scrolled = true; + window.scrollTo(0, e.offsetTop > 64 ? e.offsetTop - 64 : 0); + } + letElementBlink(e); + }); + } + } + }; + + onHashChange(); + window.addEventListener("hashchange", onHashChange); + setTimeout(()=>document.getElementsByTagName("footer")[0].classList.add("hidden"), 1000); +})