-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplements party-time as a CSS filter, with no JS needed.
- Loading branch information
Showing
3 changed files
with
22 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,3 @@ | ||
if (navigator.serviceWorker && !navigator.serviceWorker.controller) { | ||
navigator.serviceWorker.register('/sw.js'); | ||
} | ||
|
||
if (document.readyState !== 'complete') { | ||
window.addEventListener('load', setupParty, false); | ||
} else { | ||
setupParty(); | ||
} | ||
|
||
function setupParty() { | ||
'use strict'; | ||
|
||
let partyOn = false; | ||
let previous = null; | ||
let hue = parseInt( | ||
window | ||
.getComputedStyle(document.body) | ||
.getPropertyValue('--base-background-hue'), | ||
10 | ||
); | ||
|
||
window.toggleParty = () => { | ||
if (partyOn) { | ||
partyOn = false; | ||
previous = null; | ||
return; | ||
} | ||
|
||
partyOn = true; | ||
|
||
function updateParty(now) { | ||
if (!partyOn) { | ||
return; | ||
} | ||
|
||
const dt = previous === null ? 0 : now - previous; | ||
|
||
previous = now; | ||
hue = (hue + dt / 10) % 256; | ||
document.documentElement.style.setProperty('--base-background-hue', hue); | ||
window.requestAnimationFrame(updateParty); | ||
} | ||
|
||
window.requestAnimationFrame(updateParty); | ||
}; | ||
|
||
const $partyButton = document.querySelector('.party'); | ||
|
||
if ($partyButton) { | ||
$partyButton.onclick = window.toggleParty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<p>Copyright Mark Everitt 2015-{{year}}. | ||
<a href="https://ko-fi.com/qubyte" rel="payment">Donate</a> to support this blog and my OS work. <button class="party">Party on! 🥳🦜</button></p> | ||
<a href="https://ko-fi.com/qubyte" rel="payment">Donate</a> to support this blog and my OS work. <input id="party-time" type="checkbox"/><label for="party-time">Party on! </label></p> |