0

I am having a heck of a time with this. I am using Animisition to load my pages (GitHub) which works fine. I have other animations that are also on the page but I dont want those to run until the Animisition page animation is done. I tried binding a function to the animations

 $("body").one("animationend webkitAnimationEnd mozAnimationEnd oAnimationEnd MSAnimationEnd", function() {

     setTimeout(function() {
         //$('body').chardinJs('start');
         console.log('timer');
     }, 2000);

 });

but this doesnt work. The log happens before the animation is done. At the end of the animation the body gets a style of opacity:1. Is there a way to bind a function to that? or check if that whole js file is done running?

Sushil
  • 2,811
  • 4
  • 17
  • 28
Packy
  • 2,955
  • 8
  • 39
  • 76
  • 1
    Does the library provide a callback that runs when the animation ends? Put your code there. – Barmar May 01 '15 at 17:32
  • The documentation seems to be very sparse, I can't tell if it has a way to do this. – Barmar May 01 '15 at 17:36
  • Ya, not a lot to go on. – Packy May 01 '15 at 17:44
  • In the source code I see `$.fn.animateCallback`; have you tried passing a callback to that? – Matt Browne May 01 '15 at 18:00
  • Ideally there'd be an event you could bind to or a callback function you can passn. As a hack, you could do a `setInterval` or repeating `setTimeout` to check the opacity of the body until it's set to one, and then run your code (and stop checking the opacity, of course) but that feels dirty. – Thriggle May 01 '15 at 18:00
  • I can see the `animation-loading` class in the docs in the github link you provided, and there should be `animsition-loading` visible while the animation is running. using a `settimeout` of every second and get the class visibliity and if visible don't run your animation if it is not visible the start running your custom animations. – Lucky May 01 '15 at 18:08
  • @Lucky can you explain further? or provide an example. I think I know what you mean. – Packy May 01 '15 at 18:16
  • http://stackoverflow.com/a/178450/1793718 check for element is visible in a settimeout and `animsition-loading` is not visible then it has stopped running and if so it will return false and try running your animations then..but i dont know its proper way to do this or i haven't tried it..you could contact the support for that project in github for a correct way to do this.. – Lucky May 01 '15 at 18:23

0 Answers0