[求助]让Lightbox秀出的图片可以等比缩放
以下是Lightbox文件中的lightbox.js包含的一段代码,感觉只要修改这一段就可以达到目的,请问可以帮忙实现吗?
改的原因是:可能某些图片很大,甚至超过了1024*768屏幕边界,这是Lightbox出来的效果就很差了,因此…………嘿嘿!谢谢大家啦^_^
[Copy to clipboard]CODE:
resizeImageContainer: function( imgWidth, imgHeight) {
// get current height and width
this.wCur = Element.getWidth('outerImageContainer');
this.hCur = Element.getHeight('outerImageContainer');
// scalars based on change from old to new
this.xScale = ((imgWidth + (borderSize * 2)) / this.wCur) * 100;
this.yScale = ((imgHeight + (borderSize * 2)) / this.hCur) * 100;
// calculate size difference between new and old image, and resize if necessary
wDiff = (this.wCur - borderSize * 2) - imgWidth;
hDiff = (this.hCur - borderSize * 2) - imgHeight;
if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); }
// if new and old image are same size and no scaling transition is necessary,
// do a quick pause to prevent image flicker.
if((hDiff == 0) && (wDiff == 0)){
if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);}
}
Element.setHeight('prevLink', imgHeight);
Element.setHeight('nextLink', imgHeight);
Element.setWidth( 'imageDataContainer', imgWidth + (borderSize * 2));
this.showImage();
},