Merge latest changes from default
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 11 Jul 2022 23:18:14 +0200
changeset 3538 d6c9da8d594e
parent 3537 cb7db021280c (current diff)
parent 3536 4ee33be5b8b6 (diff)
child 3539 c2eec6aae07e
Merge latest changes from default
--- a/svghmi/svghmi.js	Mon Jul 11 22:21:20 2022 +0200
+++ b/svghmi/svghmi.js	Mon Jul 11 23:18:14 2022 +0200
@@ -60,8 +60,17 @@
 var requestAnimationFrameID = null;
 function animate() {
     // Do the page swith if any one pending
-    if(current_subscribed_page != current_visible_page){
-        switch_visible_page(current_subscribed_page);
+    if(page_switch_in_progress){
+        if(current_subscribed_page != current_visible_page){
+            switch_visible_page(current_subscribed_page);
+        }
+
+        page_switch_in_progress = false;
+
+        if(page_fading_in_progress){
+            svg_root.classList.remove("fade-out-page");
+            page_fading_in_progress = false;
+        }
     }
 
     while(widget = need_cache_apply.pop()){
@@ -391,6 +400,7 @@
 var current_subscribed_page;
 var current_page_index;
 var page_node_local_index = hmi_local_index("page_node");
+var page_switch_in_progress = false;
 
 function toggleFullscreen() {
   let elem = document.documentElement;
@@ -418,11 +428,12 @@
 };
 
 function switch_page(page_name, page_index) {
-    if(current_subscribed_page != current_visible_page){
+    if(page_switch_in_progress){
         /* page switch already going */
         /* TODO LOG ERROR */
         return false;
     }
+    page_switch_in_progress = true;
 
     if(page_name == undefined)
         page_name = current_subscribed_page;
@@ -514,9 +525,6 @@
     }
 
     svg_root.setAttribute('viewBox',new_desc.bbox.join(" "));
-    if(page_fading_in_progress)
-        svg_root.classList.remove("fade-out-page");
-        page_fading_in_progress = false;
     current_visible_page = page_name;
 };
 
--- a/svghmi/widget_input.ysl2	Mon Jul 11 22:21:20 2022 +0200
+++ b/svghmi/widget_input.ysl2	Mon Jul 11 23:18:14 2022 +0200
@@ -65,6 +65,8 @@
     const "have_edit","string-length($edit_elt)>0";
     value "$edit_elt";
 
+    const "action_elements", "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]";
+
     if "$have_value"
     |     frequency: 5,
     |     dispatch: function(value) {
@@ -94,6 +96,9 @@
     |     },
     }
 
+    foreach "$action_elements" {
+    |     action_elt_«position()»: id("«@id»"),
+    }
     |     init: function() {
 
     if "$have_edit" {
@@ -104,8 +109,8 @@
     |         this.animate();
     }
 
-    foreach "$hmi_element/*[regexp:test(@inkscape:label,'^[=+\-].+')]" {
-    |         id("«@id»").onclick = () => this.on_op_click("«func:escape_quotes(@inkscape:label)»");
+    foreach "$action_elements" {
+    |         this.action_elt_«position()».onclick = () => this.on_op_click("«func:escape_quotes(@inkscape:label)»");
     }
 
     if "$have_value" {