# HG changeset patch # User Edouard Tisserant # Date 1655286408 -7200 # Node ID dacf329abdd93baf1b29fc9a34038c6d31eb6b32 # Parent d3cf85a3c282a791a671be62d54e9090f12bd199 SVGHMI: update generated xslt files diff -r d3cf85a3c282 -r dacf329abdd9 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Wed Jun 15 11:43:51 2022 +0200 +++ b/svghmi/gen_index_xhtml.xslt Wed Jun 15 11:46:48 2022 +0200 @@ -1,5 +1,5 @@ - + @@ -5442,13 +5442,11 @@ would be an HMI_TREE index and then jump to a relative page not hard-coded in advance */ - - if(!that.disabled) { const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined; - switch_page(name, index); + fading_page_switch(name, index); } @@ -5579,6 +5577,37 @@ + + + + + /* + + */ + + + + .fade-out-page { + + animation: fadeOut 0.6s both; + + } + + + + @keyframes fadeOut { + + 0% { opacity: 1; } + + 100% { opacity: 0; } + + } + + + + + + @@ -7590,17 +7619,51 @@ frequency = 5; + current_value = undefined; + + + + init(){ + + this.animate(); + + } + + + dispatch(value) { + this.current_value = value; + + this.request_animate(); + + } + + + + animate(){ + for(let choice of this.choices){ - if(value != choice.value){ - - choice.elt.setAttribute("style", "display:none"); + if(this.current_value != choice.value){ + + if(choice.parent == undefined){ + + choice.parent = choice.elt.parentElement; + + choice.parent.removeChild(choice.elt); + + } } else { - choice.elt.setAttribute("style", choice.style); + if(choice.parent != undefined){ + + choice.parent.appendChild(choice.elt); + + choice.parent = undefined; + + } } @@ -7627,9 +7690,7 @@ "), - style:" - - ", + parent:undefined, value: @@ -9179,6 +9240,7 @@ @@ -10614,6 +10676,30 @@ + + + var page_fading_in_progress = false; + + function fading_page_switch(...args){ + + svg_root.classList.add("fade-out-page"); + + page_fading_in_progress = true; + + + + setTimeout(function(){ + + switch_page(...args); + + },1); + + } + + document.body.style.backgroundColor = "black"; + + + // subscribe to per instance current page hmi variable // PLC must prefix page name with "!" for page switch to happen @@ -10628,7 +10714,7 @@ if(value.startsWith("!")) - switch_page(value.slice(1)); + fading_page_switch(value.slice(1)); } @@ -11214,6 +11300,12 @@ 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; };