2 Replies Latest reply on Dec 4, 2014 12:18 PM by HayPro

    Starting animation only when scrolled to container

    HayPro

      There is a good article about that.http://www.raymondcamden.com/2013/12/6/Delaying-an-Edge-Animate-asset-until-visible--Part- 4.

       

      // insert code to be run when the symbol is created here
      var wasHidden = true;
      
          //http://stackoverflow.com/a/488073/52160
          function isScrolledIntoView(elem) {
              var docViewTop = $(window.parent).scrollTop();
              var docViewBottom = docViewTop + $(window.parent).height();
      
              var elemTop = $(elem).offset().top;
              var elemBottom = elemTop + $(elem).height();
      
              return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
                && (elemBottom <= docViewBottom) &&  (elemTop >= docViewTop) );
          }          
      
          var element = sym.element;
          element = $("#graphics", window.parent.document);
      
          if(isScrolledIntoView(element)) {
              console.log('on load vis');
              wasHidden=false;
              sym.play();
          }
      
          function doStart() {
              if(isScrolledIntoView(element)) {
                  if(wasHidden) {
                      console.log('Start me up ID5');    
                      sym.play();
                  }
                  wasHidden = false;
              } else {
                  sym.stop();
                  wasHidden = true;
              }
      
          }
      
          $(window.parent).on("scroll", doStart);
      
      

       

      But the problem is this code doesn't work with Edge Animate CC 2014.

      Are there any ideas how to adapt the code for newest version of Edge Animate?

      Thanks.