word/memory: celebration animation on completion
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 23 Dec 2021 01:27:04 +0000 (02:27 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 31 Dec 2021 04:29:05 +0000 (05:29 +0100)
word/memory.js
word/memory.plp

index 0e523a1c7857fa7832abd14d6f180dd7a13ca27a..c3adfd4590d3d7dd6e4edc519620a84b8442b78f 100644 (file)
@@ -26,6 +26,9 @@ class WordMemory {
                        // lock both as correct
                        this.turned.forEach(card => put(card, '.good![onclick]'));
                        this.turned = [];
                        // lock both as correct
                        this.turned.forEach(card => put(card, '.good![onclick]'));
                        this.turned = [];
+                       if (Array.from(this.form.children).every(card => card.classList.contains('good'))) {
+                               put(this.form, '.good');
+                       }
                        return;
                }
 
                        return;
                }
 
index 8847713d0bfbcbb44a3388f30ca12002a317efc7..1bb8cebb3ae6211b609e4bf14fa513ef4776410a 100644 (file)
@@ -6,6 +6,10 @@ Html({
 <script src="/word/memory.js"></script>
 <style>
 /* cards */
 <script src="/word/memory.js"></script>
 <style>
 /* cards */
+html {
+       overflow: hidden; /* rotation overflow on celebration */
+}
+
 figure {
        display: inline-block;
        background: #224;
 figure {
        display: inline-block;
        background: #224;
@@ -42,6 +46,17 @@ figure.bad img {
 figure.good {
        opacity: .8;
 }
 figure.good {
        opacity: .8;
 }
+
+.good figure {
+       animation: celebration 5s linear infinite;
+       background: none;
+       border: 0;
+}
+@keyframes celebration {
+       0% { filter: hue-rotate(0deg); transform: rotate(0deg) }
+       50% { filter: hue-rotate(180deg); transform: rotate(180deg) }
+       100% { filter: hue-rotate(360deg); transform: rotate(360deg) }
+}
 </style>
 EOT
 });
 </style>
 EOT
 });