DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Scriptaculous JavaScript Slideshow

01.31.2006
| 37799 views |
  • submit to reddit
        Found this amazing code by obie at <a href="http://blog.caboo.se/articles/2006/01/19/easy-scriptaculous-slideshow">http://blog.caboo.se/articles/2006/01/19/easy-scriptaculous-slideshow</a>:

var album = { 
  startup: function() { 
    new PeriodicalExecuter(album.cycle, 5) // change image every 5 seconds 
  }, 
  cycle: function() { 
    new Effect.Fade('image', { // the id of the <DIV> containing the photos 
      duration: 1, 
      fps: 50, 
      afterFinish: function() { 
        new Ajax.Updater('image','/album/next', { // URL for next <IMG> tag 
          asynchronous: true, 
          onSuccess: function() { 
            new Effect.Appear('image', {
              duration: 1,
              fps: 50,
              queue:'end'
            })
          } 
        }) 
      } 
    }) 
  } 
} 
 
window.onload = album.startup

I want to tweak it so that an earlier event precaches the next image instead.