mirror of
https://github.com/tachiyomiorg/website.git
synced 2024-12-21 07:31:58 +01:00
Move script to file
This commit is contained in:
parent
d9b1b92b08
commit
008883b908
22
src/assets/js/script.js
Normal file
22
src/assets/js/script.js
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
@ -135,29 +135,6 @@
|
|||||||
<script src="assets/js/bootstrap-4.3.1.min.js"></script>
|
<script src="assets/js/bootstrap-4.3.1.min.js"></script>
|
||||||
<script src="assets/js/bootstrap-toc-1.0.1.min.js"></script>
|
<script src="assets/js/bootstrap-toc-1.0.1.min.js"></script>
|
||||||
<!-- Convenience script -->
|
<!-- Convenience script -->
|
||||||
<script>
|
<script src="assets/js/script.js"></script>
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user