Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, here's my poke at it. The preloader is in vanilla js and the slideshow loop is in jQuery. It's very simple to implement and the concept is even simpler.</p> <h2><a href="http://jsfiddle.net/6Prdv/" rel="nofollow">Demo</a></h2> <p>a very simple Demo that illustrates the DOM manipulation approach</p> <hr> <h2>HTML</h2> <pre><code>&lt;!-- not much here... just a container --&gt; &lt;div id="content"&gt;&lt;/div&gt; </code></pre> <h2>CSS</h2> <pre><code>/* just the important stuff here. The demo has example styling. */ #content { position:relative; } #content img { position:absolute; } </code></pre> <h2>javascript/jQuery</h2> <pre><code>// simple array var images = [ "http://imaging.nikon.com/lineup/dslr/d90/img/sample/pic_003t.jpg", "http://imaging.nikon.com/lineup/dslr/d90/img/sample/pic_005t.jpg", "http://imaging.nikon.com/lineup/dslr/d90/img/sample/pic_001t.jpg" ]; // some adjustable variables var delay = 2000; var transition = 1000; // the preloader for(var i in images) { var img = document.createElement("img"); img.src = images[i]; img.onload = function(){ var parent = document.getElementById("content"); parent.insertBefore(this,parent.childNodes[0]); if(i == images.length - 1) { i = 0; startSlides(); } } } // and the actual loop function startSlides() { $("#content img:last").delay(delay).fadeTo(transition,0,function(){ $(this).insertBefore($(this).siblings(":first")).fadeTo(0,1); startSlides(); }); } </code></pre> <hr> <p>The concept in brief is to fade the first image in a container, once complete change it's position in the DOM (effectively hiding it behind equal tree level siblings), and call the function again. The reason why this works is because it only fades the first child of the container, but on callback it changes what node that is constantly looping the nodes. This makes for a very small source file that is quite effective.</p> <h2>EDIT 1:</h2> <hr> <p>and 32 minutes tweaking later...</p> <h3><a href="http://jsfiddle.net/6Prdv/1/" rel="nofollow">Demo 2</a></h3> <h2>EDIT 2:</h2> <hr> <p>My oh so simple script is now very complicated :P I added in some scaling features that only work on modern browsers but are there if needed. This one also has a loading bar as it preloads the images (may or may not be desirable :P)</p> <p><a href="http://jsfiddle.net/6Prdv/4/" rel="nofollow">small images demo</a></p> <p><a href="http://jsfiddle.net/6Prdv/5/" rel="nofollow">large images demo</a></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. 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.
    3. 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