我正在尝试调整容器的大小并为其设置宽度和高度。这不是代码的全部部分,但出现无限循环然后我调用 $.fn.imageScale.resizeContainer函数,我找不到为什么?
$( window ).load(function(){
$( '#scalable_images' ).imageScale();
});
(function($){
$.fn.imageScale = function(){
thisCallback = $( this ); // for usage in inner other function
images = $( this ).find( 'img' ); // images
imagesHolder = $( this ).find( '.item' ); // image holder
frameSize = 34; // frame size
sizingCof = 1.5; // image size cofficient to scale, 1.5 = 150% normal state
speed = 600; // speed in ms
$.fn.imageScale.resizeContainer();
$.fn.imageScale.resize();
OldContainerW = imagesHolder.width();
OldOffsetL = offsetL;
$( window ).bind( 'resize', function(){
$.fn.imageScale.resizeContainer();
$.fn.imageScale.resize();
OldContainerW = imagesHolder.width();
OldOffsetL = offsetL;
});
}
$.fn.imageScale.resizeContainer = function(){
var windowW = $( window ).width();
var windowH = $( window ).height();
var scaleImgH = windowH - frameSize * 2;
var scaleImgW = windowW - frameSize * 2;
$( this ).height( scaleImgH );
$( this ).width( scaleImgW );
}
})(jQuery);