refactor Preload

This commit is contained in:
Andy Edinborough 2012-12-30 12:20:35 -06:00
parent 3774f3655c
commit 6ce619f0c0
2 changed files with 20 additions and 18 deletions

View File

@ -51,7 +51,7 @@ _html2canvas.Util.parseBackgroundImage = function (value) {
}
results.push({
prefix: prefix,
method: method,
method: method.toLowerCase(),
value: block,
args: args
});

View File

@ -126,28 +126,30 @@ _html2canvas.Preload = function( options ) {
background_images = _html2canvas.Util.parseBackgroundImage(background_image);
while(!!(background_image = background_images.shift())) {
if(!background_image ||
!background_image.method ||
!background_image.args ||
background_image.args.length === 0 ) {
continue;
}
if ( background_image.value && background_image.value !== "1" && background_image.value !== "none" ) {
if (/^(-webkit|-o|-moz|-ms|linear)-/.test( background_image.method )) {
if (background_image.method === 'url') {
src = background_image.args[0];
methods.loadImage(src);
img = _html2canvas.Generate.Gradient( background_image.value, _html2canvas.Util.Bounds( el ) );
} else if( background_image.method.match( /\-gradient$/ ) ) {
img = _html2canvas.Generate.Gradient( background_image.value, _html2canvas.Util.Bounds( el ) );
if ( img !== undefined ){
images[background_image.value] = {
img: img,
succeeded: true
};
images.numTotal++;
images.numLoaded++;
start();
if ( img !== undefined ){
images[background_image.value] = {
img: img,
succeeded: true
};
images.numTotal++;
images.numLoaded++;
start();
}
} else {
src = _html2canvas.Util.backgroundImage(background_image.value);
methods.loadImage(src);
}
}
}
}