svghmi/svghmi.js
changeset 3535 770fcb344f50
parent 3524 27d298c6f961
child 3553 406eb8a13648
equal deleted inserted replaced
3525:c2f7e9bda366 3535:770fcb344f50
    58 
    58 
    59 // Called on requestAnimationFrame, modifies DOM
    59 // Called on requestAnimationFrame, modifies DOM
    60 var requestAnimationFrameID = null;
    60 var requestAnimationFrameID = null;
    61 function animate() {
    61 function animate() {
    62     // Do the page swith if any one pending
    62     // Do the page swith if any one pending
    63     if(current_subscribed_page != current_visible_page){
    63     if(page_switch_in_progress){
    64         switch_visible_page(current_subscribed_page);
    64         if(current_subscribed_page != current_visible_page){
       
    65             switch_visible_page(current_subscribed_page);
       
    66         }
       
    67 
       
    68         page_switch_in_progress = false;
       
    69 
       
    70         if(page_fading_in_progress){
       
    71             svg_root.classList.remove("fade-out-page");
       
    72             page_fading_in_progress = false;
       
    73         }
    65     }
    74     }
    66 
    75 
    67     while(widget = need_cache_apply.pop()){
    76     while(widget = need_cache_apply.pop()){
    68         widget.apply_cache();
    77         widget.apply_cache();
    69     }
    78     }
   389 
   398 
   390 var current_visible_page;
   399 var current_visible_page;
   391 var current_subscribed_page;
   400 var current_subscribed_page;
   392 var current_page_index;
   401 var current_page_index;
   393 var page_node_local_index = hmi_local_index("page_node");
   402 var page_node_local_index = hmi_local_index("page_node");
       
   403 var page_switch_in_progress = false;
   394 
   404 
   395 function toggleFullscreen() {
   405 function toggleFullscreen() {
   396   let elem = document.documentElement;
   406   let elem = document.documentElement;
   397 
   407 
   398   if (!document.fullscreenElement) {
   408   if (!document.fullscreenElement) {
   416         parent.removeChild(element);
   426         parent.removeChild(element);
   417     }
   427     }
   418 };
   428 };
   419 
   429 
   420 function switch_page(page_name, page_index) {
   430 function switch_page(page_name, page_index) {
   421     if(current_subscribed_page != current_visible_page){
   431     if(page_switch_in_progress){
   422         /* page switch already going */
   432         /* page switch already going */
   423         /* TODO LOG ERROR */
   433         /* TODO LOG ERROR */
   424         return false;
   434         return false;
   425     }
   435     }
       
   436     page_switch_in_progress = true;
   426 
   437 
   427     if(page_name == undefined)
   438     if(page_name == undefined)
   428         page_name = current_subscribed_page;
   439         page_name = current_subscribed_page;
   429     else if(page_index == undefined){
   440     else if(page_index == undefined){
   430         [page_name, page_index] = page_name.split('@')
   441         [page_name, page_index] = page_name.split('@')
   512             parent.appendChild(element);
   523             parent.appendChild(element);
   513         }
   524         }
   514     }
   525     }
   515 
   526 
   516     svg_root.setAttribute('viewBox',new_desc.bbox.join(" "));
   527     svg_root.setAttribute('viewBox',new_desc.bbox.join(" "));
   517     if(page_fading_in_progress)
       
   518         svg_root.classList.remove("fade-out-page");
       
   519         page_fading_in_progress = false;
       
   520     current_visible_page = page_name;
   528     current_visible_page = page_name;
   521 };
   529 };
   522 
   530 
   523 // Once connection established
   531 // Once connection established
   524 ws.onopen = function (evt) {
   532 ws.onopen = function (evt) {