Explorar el Código

[bug] Skip all non existent variants.

Marcelo Fornet hace 4 años
padre
commit
0099877a2c
Se han modificado 1 ficheros con 9 adiciones y 8 borrados
  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;