function showImg(){
pw = parseInt( $(this).parent().css('width') );
ph = parseInt( $(this).parent().css('height') );
showImage = new Image();
showImage.src = $(this).children('a').children('img').attr('src');
sw = showImage.width;
sh = showImage.height;
//原先这些sw是直接用 $(this).width()来判断,但实际上很多时间都取回的是pager里面的图片大小属性,或者取回来有不正常的时候,这是cycle的BUG,没有时间却验证了,因此,只有用Image类来进行处理,这样取回来的就是图片真正的大小
idx = $('#bigPic li').index( $(this) );
alert(showImage.src+' - '+sw+' - '+sh);
if (sw > pw || sh > ph){
if (sw > sh ){
sh = Math.floor(sh * ( pw / sw ));
sw = pw-10;
}else {
sw = Math.floor(sw * ( ph / sh ));
sh = ph-10;
}
//实在不知道这里为什么会多出16px,如果不减6,就会每次缩小
//这里的长宽比例会不正确。。。
$(this).children('a').children('img').css({'width': sw,'height':sh,'paddingTop':3});
}
if (sh <= ph){
$(this).css('marginTop',(ph - sh)/2).css('verticalAlign','middle');
}
if (sw <= pw){
$(this).css('marginLeft' , (pw - sw)/2).css('textAlign','center');
}
if( idx == 0 ){
$('#thumbnail a').trigger('click');
}
}
Mark it ,and update it on work time...

评论 (0)
暂无评论