Prechádzať zdrojové kódy

[bug] Skip all non existent variants.

Marcelo Fornet 4 rokov pred
rodič
commit
0099877a2c
1 zmenil súbory, kde vykonal 9 pridanie a 8 odobranie
  1. 9 8
      static/js/image-modal.js

+ 9 - 8
static/js/image-modal.js

@@ -22,21 +22,22 @@
     function imgPrev() {
         var work = Number.parseInt(dialog.dataset.work);
         var variant = Number.parseInt(dialog.dataset.variant) - 1;
-        if (variant < 0) {
-            work -= 1;
-            if (work < 0) {
-                work = figures.length - 1;
+        while (variant == -1) {
+            if (variant < 0) {
+                work -= 1;
+                if (work < 0) {
+                    work = figures.length - 1;
+                }
+                const datalist = figures[work].lastElementChild;
+                variant = datalist.children.length - 1;
             }
-            const datalist = figures[work].lastElementChild;
-            variant = datalist.children.length - 1;
         }
         updateImage(work, variant);
     };
     function imgNext() {
         var work = Number.parseInt(dialog.dataset.work);
         var variant = Number.parseInt(dialog.dataset.variant) + 1;
-        const datalist = figures[work].lastElementChild;
-        if (variant >= datalist.children.length) {
+        while (variant >= figures[work].lastElementChild.children.length) {
             work += 1;
             if (work >= figures.length) {
                 work = 0;