]> git.ardis.lu - ard.is/commitdiff
Add random 0 to 5s animation delay
authorArdis Lu <ardisglu@gmail.com>
Fri, 6 Jun 2025 06:21:52 +0000 (23:21 -0700)
committerArdis Lu <ardisglu@gmail.com>
Fri, 6 Jun 2025 06:21:52 +0000 (23:21 -0700)
It is better aesthetically if each effect flickers out of sync, to show their independence.

index.html

index d59fad966a401a819284ea0292457d0624919931..afee7de5f7acf07212e212525d91e7648086f75c 100644 (file)
@@ -82,7 +82,7 @@
         inline-size: 100%;
         block-size: 100%;
         border-radius: 2ch;
-        animation: flicker 1s linear infinite alternate;
+        animation: flicker 1s linear var(--delay) infinite alternate;
       }
 
       &.color {
     // Add hidden effect
     const colorEffect = document.createElement('button');
     colorEffect.classList.add('effect', 'color');
+    colorEffect.style.setProperty('--delay', `${Math.floor(Math.random() * 5000)}ms`);
     const highlightStyle = document.createElement('style');
     document.head.appendChild(highlightStyle);
     colorEffect.addEventListener('click', e => {
     // Add hidden effect 2
     const translateEffect = document.createElement('button');
     translateEffect.classList.add('effect', 'translate');
+    translateEffect.style.setProperty('--delay', `${Math.floor(Math.random() * 5000)}ms`);
     translateEffect.addEventListener('click', e => {
       e.target.textContent = '!';
 
This page took 0.036864 seconds and 4 git commands to generate.