Minor minify to Milieu script
This commit is contained in:
parent
97ee8b20f4
commit
53ac2d61c0
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
<canvas id="ambient-canvas-1"/>
|
<canvas id="ambient-canvas-1"/>
|
||||||
<canvas id="ambient-canvas-2"/>
|
<canvas id="ambient-canvas-2"/>
|
||||||
|
|
||||||
|
@ -48,7 +47,7 @@ const drawFrame = () => {
|
||||||
transitionToEvenCanvas()
|
transitionToEvenCanvas()
|
||||||
}
|
}
|
||||||
oddFrame = !oddFrame
|
oddFrame = !oddFrame
|
||||||
};
|
}
|
||||||
|
|
||||||
const transitionToOddCanvas = () => {
|
const transitionToOddCanvas = () => {
|
||||||
oddCanvas.style.opacity = canvasOpacity
|
oddCanvas.style.opacity = canvasOpacity
|
||||||
|
@ -60,26 +59,16 @@ const transitionToEvenCanvas = () => {
|
||||||
oddCanvas.style.opacity = "0"
|
oddCanvas.style.opacity = "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
const drawStart = () => {
|
const drawStart = () => {intervalId = window.setInterval(drawFrame, frameIntervalMs)}
|
||||||
intervalId = window.setInterval(drawFrame, frameIntervalMs)
|
|
||||||
}
|
|
||||||
|
|
||||||
const drawPause = () => {
|
const drawPause = () => {if (intervalId) window.clearInterval(intervalId)}
|
||||||
if (intervalId) window.clearInterval(intervalId)
|
|
||||||
}
|
|
||||||
|
|
||||||
const init = () => {
|
const init = () => {
|
||||||
|
AMvideo.pause()
|
||||||
//fixes a issue where firefox/chromium fails to load the ambinet mode and doesnt load it. - please dont remove this line lmao
|
AMvideo.play()
|
||||||
|
|
||||||
AMvideo.pause();AMvideo.play();
|
|
||||||
|
|
||||||
// DO NOT REMOVE
|
|
||||||
|
|
||||||
AMvideo.addEventListener("play", drawStart, false)
|
AMvideo.addEventListener("play", drawStart, false)
|
||||||
AMvideo.addEventListener("pause", drawPause, false)
|
AMvideo.addEventListener("pause", drawPause, false)
|
||||||
AMvideo.addEventListener("ended", drawPause, false)
|
AMvideo.addEventListener("ended", drawPause, false)
|
||||||
|
|
||||||
oddCanvas.style.transition = evenCanvas.style.transition = `opacity ${frameIntervalMs}ms`
|
oddCanvas.style.transition = evenCanvas.style.transition = `opacity ${frameIntervalMs}ms`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +76,7 @@ const cleanup = () => {
|
||||||
AMvideo.removeEventListener("play", drawStart)
|
AMvideo.removeEventListener("play", drawStart)
|
||||||
AMvideo.removeEventListener("pause", drawPause)
|
AMvideo.removeEventListener("pause", drawPause)
|
||||||
AMvideo.removeEventListener("ended", drawPause)
|
AMvideo.removeEventListener("ended", drawPause)
|
||||||
drawPause();
|
drawPause()
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("load", init)
|
window.addEventListener("load", init)
|
||||||
|
|
Loading…
Reference in a new issue