Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Because the implementation of a timer wasn't possible, I ended up with a hole different solution, it's a kind of brut-force-running the animation within a setInterval:</p> <pre><code>function animate(elementId,pictureTimeArrayName){ var elementStyle = document.getElementById(elementId).style; var pictureTimeArray = window[pictureTimeArrayName]; function toInterval(startDate, timeSinceStart, picture){ var interval = setInterval(function(){ if(Date.now()-startDate&gt;=timeSinceStart){ clearInterval(interval); elementStyle.background = "url("+picture+")"; } },2); } setInterval(function(){ var startDate = Date.now(); for(var i=0;i&lt;pictureTimeArray.length;i++){ toInterval(startDate,pictureTimeArray[i].time,pictureTimeArray[i].picture); } },pictureTimeArray[pictureTimeArray.length-1].time); } </code></pre> <p>While an array looks like this:</p> <pre><code>var array_1 = [{picture: "animations/pic_1.gif", time: "30"}, {picture: "animations/pic_2.gif", time: "60"}, ... {picture: "animations/pic_36.gif", time: "1080"},]; </code></pre> <p>This looks quite good (for >=30 fps). But: When an animated Gif is running, it's still not that smooth anymore. And if it is an animation repeating itself, the drawings aren't always clean. In some never browser versions (from Firefox) the drawing is even worse than in older versions, and other browsers (Chrome) have their problems, too. Especially if you change the browser window in Chrome and get back to the window: The animation will look really weird.</p> <p>So you probably better use Flash or another non-Javascript-solution for your professional animations.</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.
 

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