//$(function (){ var x = 0; //cont = $(".content"), bottom = $(".bottom"); var img = new image(); var width_per,height_per; function img_block(){ var img_width, img_height; $(".content span").show();//鍔犺浇鍥剧墖鍑虹幇 var width = $(window).width(); //鑾峰彇娴忚鍣ㄦ樉绀哄尯鍩熺殑瀹藉害 var height = $(window).height();//鑾峰彇娴忚鍣ㄦ樉绀哄尯鍩熺殑楂樺害 $('.close_div').css({"width":(width-50)});//鍏抽棴鍖虹殑瀹藉害 $(".bottom").stop(); $(".content").stop(); $(".content .img").css("display","none");//褰撳墠鍥剧墖娑堝け $(".bottom").css({"height":"0px"});//搴曢儴鍖哄煙娑堝け $("#xz").text(x+1); //绗嚑寮犲浘鐗? //鍥剧墖鏄剧ず鍖? $(".content").animate({"width":(width-50)+"px","height":height-100+"px"},300,function (){ img.src = $(".content .img:eq("+x+")").attr("src") ;//img.width鍙幏鍙栧浘鐗囩殑瀹藉害img.height楂樺害 img_width = img.width; //img.width鍙幏鍙栧浘鐗囧搴? img_height = img.height;//img.height鍙幏鍙栧浘鐗囬珮搴? width_per = (img_width/img_height).tofixed(2); //瀹介珮鐨勬瘮渚? height_per = (img_height/img_width).tofixed(2);//瀹介珮鐨勬瘮渚? //楂樺害瓒呭嚭缃戦〉鍙鍖哄娌℃湁瓒?鎴栬€呭叏閮ㄨ秴鍑轰絾鏄彲瑙嗗尯瀹藉害澶т簬楂樺害 if(img_height >= height-100 && img_width < width-50 || img_height > height-100 && img_width > width-50 && (width-50)>(height-100)){//楂樺害瓒呭嚭鍖哄煙 img_height = height-100; img_width = parseint((height-100)*width_per); } //涓庝笂闈㈢浉鍙? if(img_width >= width-50 && img_height < height-100 || img_height > height-100 && img_width > width-50 && (width-50) < (height-100)){//瀹藉害瓒呭嚭鍖哄煙鏃? img_width = width-50; img_height = parseint((width-50)*height_per); } //閮芥病鏈夎秴鍑? if(img_height <= height-100 && img_width <= width-50){ img_height = img_height; img_height = img_height; } $(".content .img:eq("+x+")").attr('height',img_height);//璁剧疆鍥剧墖鐨勯珮 $(".content .img:eq("+x+")").attr('width',img_width);//璁剧疆鍥剧墖鐨勫 $(".content .img:eq("+x+")").css("left",(width-50-parseint(img_width))/2);//鍥剧墖姘村钩灞呬腑浣嶇疆 $(".content .img:eq("+x+")").css("top",(height-100-parseint(img_height))/2);//鍥剧墖鍨傜洿灞呬腑浣嶇疆 $(".content .img:eq("+x+")").css("display","block");//涓嬩竴寮犲浘鐗囨樉绀? $(".bottom").css("width",(width-50)+"px");//搴曢儴鍖虹殑瀹藉害 $(".bottom").animate({"height":"30px"});//搴曢儴鍖虹殑楂樺害 $(".left,.right").css({"width":(width-50)/2+"px","height":(height-100)+"px"});//宸﹀彸鍒嗗尯鐨勫搴? $(".content span").hide(); }); } $(document).ready(function() { //鏌ョ湅澶у浘 $('.see_big_pic').click(function(){ $('.container').fadein(300); //鍥剧墖鎬绘暟 $("#img_count").text($(".content .img").length); img_block(); }); //鐐瑰嚮鍥剧墖 $('.thumb_photo').click(function(){ $('.container').fadein(300); //瀹氭椂鑷姩涓嬩竴寮? x = parseint(this.title)-1; //鍥剧墖鎬绘暟 $("#img_count").text($(".content .img").length); img_block(); }); //鍏抽棴鏌ョ湅澶у浘 $('.close_pop').click(function(){ $('.container').fadeout(300); }); //鍚戝彸 $(".right").click(function (){ rights(); }); //鍚戝乏 $(".left").click(function (){ lefts(); }); }); //涓嬩竴寮? function rights(){ if(x == $(".content .img").length-1){ notification('warn','宸叉槸鏈€鍚庝竴寮?,500); //x = 0; }else{ x++; img_block(); }; } //涓婁竴寮? function lefts(){ if(x == 0){ notification('warn','宸叉槸绗竴寮?,500); //x = $(".content .img").length-1; }else{ x--; img_block(); } } //}); function seebig(obj){ $('.container').fadein(300); //瀹氭椂鑷姩涓嬩竴寮? x = parseint(obj.title)-1; //鍥剧墖鎬绘暟 $("#img_count").text($(".content .img").length); img_block(); }