SVGHMI: ForEach Widget now has a better wrap-around when scrolling : hit the boundary systematically before wrapping svghmi
authorEdouard Tisserant
Wed, 25 Mar 2020 14:09:15 +0100
branchsvghmi
changeset 2899 f1baf2d0552c
parent 2898 a2910281fcb5
child 2900 3ef217f525ff
SVGHMI: ForEach Widget now has a better wrap-around when scrolling : hit the boundary systematically before wrapping
svghmi/gen_index_xhtml.xslt
svghmi/svghmi.js
--- a/svghmi/gen_index_xhtml.xslt	Wed Mar 25 13:56:04 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Wed Mar 25 14:09:15 2020 +0100
@@ -1833,11 +1833,23 @@
 </xsl:text>
     <xsl:text>    if(new_item_offset + this.items.length &gt; this.index_pool.length) {
 </xsl:text>
-    <xsl:text>        new_item_offset = 0;
+    <xsl:text>        if(this.item_offset + this.items.length == this.index_pool.length)
+</xsl:text>
+    <xsl:text>            new_item_offset = 0;
+</xsl:text>
+    <xsl:text>        else
+</xsl:text>
+    <xsl:text>            new_item_offset = this.index_pool.length - this.items.length;
 </xsl:text>
     <xsl:text>    } else if(new_item_offset &lt; 0) {
 </xsl:text>
-    <xsl:text>        new_item_offset = this.index_pool.length - this.items.length;
+    <xsl:text>        if(this.item_offset == 0)
+</xsl:text>
+    <xsl:text>            new_item_offset = this.index_pool.length - this.items.length;
+</xsl:text>
+    <xsl:text>        else
+</xsl:text>
+    <xsl:text>            new_item_offset = 0;
 </xsl:text>
     <xsl:text>    }
 </xsl:text>
--- a/svghmi/svghmi.js	Wed Mar 25 13:56:04 2020 +0100
+++ b/svghmi/svghmi.js	Wed Mar 25 14:09:15 2020 +0100
@@ -347,9 +347,15 @@
 function foreach_onclick(opstr, evt) {
     new_item_offset = eval(String(this.item_offset)+opstr)
     if(new_item_offset + this.items.length > this.index_pool.length) {
-        new_item_offset = 0;
+        if(this.item_offset + this.items.length == this.index_pool.length)
+            new_item_offset = 0;
+        else
+            new_item_offset = this.index_pool.length - this.items.length;
     } else if(new_item_offset < 0) {
-        new_item_offset = this.index_pool.length - this.items.length;
+        if(this.item_offset == 0)
+            new_item_offset = this.index_pool.length - this.items.length;
+        else
+            new_item_offset = 0;
     }
     this.item_offset = new_item_offset;
     off = this.offset;