javascript - Check when the page is loaded AND opening animation has finished -


i'm in front of conceptual problem.
@ beginning of site have opening animation (in sostitution of loader) want show all, beginning end, of course. when page loaded i'll show page.

now there 2 different situations:

  • first: fast internet -> page loaded before animation over
  • second: slow internet -> opening finish before end of loading

what want achieve show entire opening , if page loaded close opening/loader, or if page not loaded wait until end of loading close opening/loader.

i thought use $(windows).load("close loader") in case of loading fast loader closed before end of animation.

what tried

$(window).load(function(){         if( done ){             console.log("bar done");             $("#openingloader").addclass("done");         }         done = true;     }); 

and in callback of opening animation

if( done ){         console.log("opening done");         $("#openingloader").addclass("done");         } done = true; 

but don't think way solve that. ideas?

you have 2 conditions in question, 1 condition each of tried solutions.

set callback page load function when either animation finishes or page loads. page load function needs check if both conditions fulfilled, , if - open page.

pseudo code:

animationfinishedcallback = function(){   animationfinished = true;   trypageopen(); } pageloadedcallback = function(){   pageloaded = true;   trypageopen(); }  function trypageopen() {   if (animationfinished && pageloaded) {      openpage();   } } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -