diff --git a/src/assets/js/script.js b/src/assets/js/script.js new file mode 100644 index 00000000..791f9802 --- /dev/null +++ b/src/assets/js/script.js @@ -0,0 +1,22 @@ +addEventListener("hashchange", () => { + var q = document.querySelector(location.hash) + if (q instanceof HTMLHeadingElement && q.parentElement.parentElement instanceof HTMLDetailsElement) + q.parentElement.parentElement.open = true; +}) +if (location.hash) requestAnimationFrame(() => dispatchEvent(new HashChangeEvent("hashchange"))); +if ('IntersectionObserver' in self) { + const mo = new IntersectionObserver(i => { + for (const s of i) { + /** @type {HTMLVideoElement} */ + const v = s.target; + if (s.isIntersecting && v.paused) { + v.load() + v.play() + } else if (!v.paused) v.pause() + } + }) + for (let v of document.querySelectorAll('video')) { + mo.observe(v) + v.controls = false + } +} diff --git a/src/index.html b/src/index.html index ba7c2d12..e21f8ab1 100644 --- a/src/index.html +++ b/src/index.html @@ -135,29 +135,6 @@ - +