]> _ Git - Animations.git/commitdiff
wip #4292 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Mar 2021 18:56:48 +0000 (19:56 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Mar 2021 18:56:48 +0000 (19:56 +0100)
RedbullContentMaking/p29-spin/index.html
RedbullContentMaking/p29-spin/p29-spin.zip

index 9052c59ab295f99c36acdc770ba204bc4046f2f5..565729ddfc0235693dc0e481ff79d709deb37963 100644 (file)
 <script src="../../tweenmax.js"></script>
 <script>
     var nb = 13;
-    var currentPos = 0;
+    var currentIndex = 0;
     var spinning = false;
+    var index = 0;
+
+    var list = [];
+    for (var i = 0; i < nb; i++) {
+        list.push(i);
+    }
+    list = shuffle(list);
+    var currentPos=list[0]+nb;
+
     $(function () {
-        var index = 0;
         updateCurrentPos()
 
         $("#spin").on('click', function () {
             spinning = true;
             $("#results img").removeClass('visible');
             currentPos = normIdx(currentPos);
-            var newpos = nb + (currentPos + Math.ceil(Math.random() * 9));
+            currentIndex = (currentIndex + 1) % nb;
+            var newpos = -nb+list[currentIndex];
+
             setTimeout(function () {
                 var pos = normIdx(newpos);
                 $("#i" + pos).addClass('visible');
         return (nb + i) % nb;
     }
 
+    function shuffle(a) {
+        var j, x, i;
+        for (i = a.length - 1; i > 0; i--) {
+            j = Math.floor(Math.random() * (i + 1));
+            x = a[i];
+            a[i] = a[j];
+            a[j] = x;
+        }
+        return a;
+    }
 </script>
 </body>
 </html>
\ No newline at end of file
index 0128037a9c487beeb9d3507af53aa30525e11dd7..b3b287f140683495953440cbdad50ef098dd6715 100644 (file)
Binary files a/RedbullContentMaking/p29-spin/p29-spin.zip and b/RedbullContentMaking/p29-spin/p29-spin.zip differ