Skip to content

Commit

Permalink
Better image preloading
Browse files Browse the repository at this point in the history
- using DOM to preload the images - replaced tabs with spaces
  • Loading branch information
sleepyboy committed Oct 24, 2011
1 parent 5bbe168 commit 28fb9cd
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions jquery.vegas.js
Expand Up @@ -34,8 +34,8 @@
paused = null,
backgrounds = [],
step = 0,
delay = 5000,
walk = function() {},
delay = 5000,
walk = function() {},
timer,
methods = {

Expand Down Expand Up @@ -190,9 +190,9 @@
}

backgrounds = options.backgrounds;
delay = options.delay;
delay = options.delay;
step = options.step;
walk = options.walk;
walk = options.walk;

clearInterval( timer );

Expand All @@ -215,7 +215,7 @@
if ( settings.fade > options.delay ) {
settings.fade = options.delay;
}

$.vegas( settings );
}
doSlideshow();
Expand Down Expand Up @@ -315,9 +315,12 @@

// Preload an array of backgrounds
preload: function( backgrounds ) {
var cache = [];
for( var i in backgrounds ) {
if ( backgrounds[ i ].src ) {
$('<img src="' + backgrounds[ i ].src + '">');
var cacheImage = document.createElement('img');
cacheImage.src = backgrounds[ i ].src;
cache.push(cacheImage);
}
}

Expand Down Expand Up @@ -354,10 +357,10 @@
properties = {
'width': newWidth + 'px',
'height': newHeight + 'px',
'top': 'auto',
'bottom': 'auto',
'left': 'auto',
'right': 'auto'
'top': 'auto',
'bottom': 'auto',
'left': 'auto',
'right': 'auto'
}

if ( !isNaN( parseInt( options.valign ) ) ) {
Expand Down

0 comments on commit 28fb9cd

Please sign in to comment.