Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The following settings in <code>playMove</code> will give you what you want:</p> <pre><code>i = i + 1; setTimeout('playMove( ... )', 15); </code></pre> <p>Your animation seemes sluggish because you're changing image positions <strong>rarely</strong> and with <strong><em>big jumps</em></strong>. If you want it to be <strong>smoother</strong> you should change the positions more <strong>frequently</strong> but less pixels in each step.</p> <pre><code>Old: 5 px / 75 ms New: 1 px / 15 ms </code></pre> <hr> <p><em>Sidenotes</em></p> <p>If you really care for speed, don't select elements in every call of the rendering function (<code>playMove</code>). Do this at the end of <code>show</code>before calling <code>setTimeout</code>:</p> <pre><code>// select elements by their id and replace them in the array for (var i = sImgArray.length; i--;) { sImgArray[i] = document.getElementById( sImgArray[i] ); } </code></pre> <p>Now you can simply write </p> <pre><code>sImgArray[iLeft] </code></pre> <p>instead of </p> <pre><code>document.getElementById(sImgArray[iLeft]) </code></pre> <p>in playMove and playShow.</p> <p>Secondly you should try to avoid passing functions as textual parameters because they need to be evaled separately.</p> <pre><code>// GOOD setTimeout(function() { playShow(iVisible, iImgs); }, 4000); // BAD setTimeout('playShow(' + iVisible + ',' + iImgs + ')', 4000) </code></pre> <p>Thirdly this is like the ugliest thing I've seen in my life:</p> <pre><code>setTimeout('show.call(\'index\');', 6000); </code></pre> <p>Don't use the <code>this</code> reference to pass parameter to a function. That's what normal parameterlist is for.</p> <pre><code>setTimeout(function() { show('index'); }, 4000); </code></pre> <p>Then your function <code>show</code> becomes something like this:</p> <pre><code>function show( page ) // pass string as an argument { if ( page == "index" ) { // ... </code></pre>
 

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