How to use:
$ (". Viewarea img"). Zoom ({height:74,width:103});
(function($){
$.fn.zoom= function(Settings) {
//some default configurations;
Settings=$.extend ({
Height:0,
Width:0,
Loading:"Http://www.dadachina.com/images/lightbox-ico-loading.gif"
},settings);
varImages= This;
$ (images). Hide ();
varloadding= NewImage ();
Loadding.classname="loadding"
LOADDING.SRC=settings.loading;
$ (images). After (loadding);
//Pre-load
varpreload= function($ This){
varimg= NewImage ();
IMG.SRC= $ This. src;
if(Img.complete) {
Processimg.call ($ This);
return;
}
//$this. src = loadding.src;//causes the wrong size to be obtained
Img.onload= function(){
//$this. src = this.src;//will result in getting the wrong size
Processimg.call ($ This);
Img.onload=function(){};
}
}
//calculate the image size;
functionProcessimg () {
//if (settings.height===0| | Settings.width ===0) return;
varm= This. Height-Settings.height;
varN= This. Width-Settings.width;
if(M>N)
This. Height= This. Height>Settings.height?Settings.height:
This. Height;
Else
This. Width= This. Width>Settings.width?Settings.width:
This. Width;
$( This). Next (". loadding"). Remove ()
$( This). Show ();
}
return$ (images). each (function(){
Preload ( This);
});
}
}) (jQuery);