Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hey, I got the problem. The thing is this library isn't expecting you to use multiple animations at a time. the function SKEL.EFFECTS.Slide.animate which inits the animations creates a field in the animated object, called skel_animate_id, which is in fact the id of a timer set up to do the animation. </p> <p>As this library doesn't expect multiple animations at a time, when you create a new animation, it just does <code>element.skel_animate_id = setInterval(.....</code>, and if you are following me, you'll realize that anything that was on <code>skel_aimate_id</code> before (i.e. the library's only reference to any previous animation's timers) is lost after that assignment.</p> <p>Now, there's a step function, called by the timers, which is in charge of recognizing when the animation has ended, and stop the timer itself, but it does that by calling <code>clearInterval(element.skel_animate_id);</code>, which will obviously only clear the timer related to the last attribute animated.</p> <p>Long story short, when you call the second attribute's animation (before the first one ended), you leave an open timer, which keeps on going and going "animating" the first attribute (i.e. setting it to it's final value).</p> <p><strong>EDIT:</strong> <a href="http://jsfiddle.net/FcFzc/" rel="nofollow">Live demo of fix.</a></p> <p><strong>THE GUILTY SNIPPET</strong></p> <p>Lines [488-531]</p> <pre><code>SKEL.EFFECTS.Slide = { counter: 0, fps: 50, //handles the animation from an attribute to an attribute animate: function(element,cssAttribute,from,to,duration,transition){ if(element.css('display') != 'block'){ element.skel_old_display = element.css('display'); } //if there isn't a default transition set one if(!transition){ transition = SKEL.Transitions.quadOut; } //cancel any current animation // FELIX Note: I've commented this because when we had 3 transitions on the same element, this function would make only the first one to work. //SKEL.EFFECTS.Slide.stop(element); var startTime = new Date().getTime(); //IE doesn't support arguments, so make a function that explicitly calls with those arguments element.skel_animate_id = setInterval(function(){ SKEL.EFFECTS.Slide.step(element,cssAttribute,from,to,duration,startTime,transition); },(1000/SKEL.EFFECTS.Slide.fps)); return element.skel_animate_id; }, //cancels any animation event stop: function(element){ //console.log(this,element,element.skel_animate_id); //console.log(element.skel_animate_id); if(element.skel_animate_id){ clearInterval(element.skel_animate_id); element.skel_animate_id = 0; if(element.skel_old_display){ element.css('display',element.skel_old_display); } } }, </code></pre> <p><strong>POSSIBLE SOLUTION</strong></p> <p>I'd have <code>skel_animate_ids</code> as an array, and store every interval with a reference to the attribute animated, so the step function nows which interval to clear.</p> <p>in SKEL.EFFECTS.Slide.animate</p> <pre><code>if (!element.skel_animate_ids){ element.skel_animate_ids = new Object(); } //IE doesn't support arguments, so make a function that explicitly calls with those arguments element.skel_animate_ids[cssAttribute] = setInterval(function(){ SKEL.EFFECTS.Slide.step(element,cssAttribute,from,to,duration,startTime,transition); },(1000/SKEL.EFFECTS.Slide.fps)); return element.skel_animate_ids[cssAttribute]; </code></pre> <p>then in SKEL.EFFECTS.Slide.stop</p> <pre><code>//cancels any animation event stop: function(element,attribute){ if(element.skel_animate_ids[attribute]){ clearInterval(element.skel_animate_ids[attribute]); delete element.skel_animate_ids[attribute]; if(element.skel_old_display){ element.css('display',element.skel_old_display); } } }, </code></pre> <p>and in SKEL.EFFECTS.Slide.step (line 575)</p> <pre><code>if(finished){ SKEL.EFFECTS.Slide.stop(element,cssAttribute); } </code></pre> <p>I think that should do it, but I can't really test it in my browser. If my code doesn't quite work, I must have missed something, but I'm still sure that's the problem, you just have to figure out how to solve it (or change libraries =D). You just try my suggestion, let me know how it worked.</p> <p>Cheers</p> <p><strong>EDIT:</strong> I couldn't wait, so I whipped a JSFiddle to test, and yeah, it works with those changes. <a href="http://jsfiddle.net/FcFzc/" rel="nofollow">Check it out</a>.</p> <p><strong>EDIT2:</strong> Corrected typo: was still referencing skel_animate_id instead of skel_animate_ids in the first bit of code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload