// 榛樿obj涓烘墽琛屽厓绱? // hover // 榛樿鏍峰紡 .h , 榛樿hover鏍峰紡 .hover // 鑷畾涔塇over鍙娇鐢?hover(obj, classname) $(function(){ $(".h").hover(function(){ $(this).addclass("hover") }, function(){ $(this).removeclass("hover") }) }) function hover(obj, classname) { obj.hover(function(){ $(this).addclass(classname) }, function(){ $(this).removeclass(classname) }) } // tab // 榛樿鐒︾偣鏍峰紡 .cur // 涓洪槻姝p绯荤粺opacity鍙兘鍑虹幇鐨勯敮榻挎垨杈圭紭妯$硦锛?榛樿.tabbox鏁堟灉.show() / .hide() // 鎷撳睍.tabbox鎴恛pacity锛?闇€鍦?tabbox涓婂姞涓?data-effect="true" function tab(tabbtn, tabbox) { var tabbl = true; tabbtn.eq(0).addclass("cur") tabbox.eq(0).show() tabbtn.click(function(){ var n = $(this).index(); $(this).addclass("cur").siblings().removeclass("cur") if(tabbox.attr("data-effect") == "true"){ if(!tabbl){ return } tabbl = false; tabbox.eq(n).stop().fadein(800).siblings().stop().fadeout(800, function(){ tabbl = true; }) }else{ tabbox.eq(n).show().siblings().hide() } }) } // 鍥剧墖鍏ㄥ睆 / 鍥剧墖鍏呮弧鏁翠釜鐖剁骇 // 榛樿box鑷甫loading鑳屾櫙鍥? // 榛樿obj hide function fullbg(box, obj){ box.css("background", "none") obj.eq(0).stop().fadein(1000) function resizebg() { obj.removeclass("w-f").removeclass("h-f").css("margin", 0) var boxr = box.outerwidth() / box.outerheight(), objr = obj.width() / obj.height(); if( objr < boxr ) { obj.addclass('w-f').css("margin-top", -(obj.height() - box.outerheight()) / 2); }else{ obj.addclass('h-f').css("margin-left", -(obj.width() - box.outerwidth()) / 2); } } $(window).resize(resizebg).trigger("resize"); } // 鏍囩杩涘満鏁堟灉 // 鐢ㄤ簬澶氬钩绾ф爣绛句緷娆¤浇鍏?榛樿鏍囩鍏锋湁position灞炴€у強opacuty: 0; // direction 浠庡摢涓柟鍚戣繘鍏? // distance 杩涘叆鍒版寚瀹氳窛绂? // number 骞崇骇鏍囩鐨勪釜鏁? // time 杩涘満鍔ㄧ敾鐨勬椂闂? // delay 涓嬩竴鏍囩鐨勫欢杩? function enter(obj, direction, distance, number, time, delay) { // 浠庡乏寰€鍙筹紝distance > 0 if(direction == "left"){ obj.stop().animate({ left : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() + 1 <= number){ enter(obj.next(), direction, distance, number, time, delay) } }, delay) } // 浠庝笂寰€涓嬶紝distance > 0 if(direction == "top"){ obj.stop().animate({ top : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() + 1 <= number){ enter(obj.next(), direction, distance, number, time, delay) } }, delay) } // css3 x浣嶇щ if(direction == "x"){ obj.stop().transition({ x : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() + 1 <= number){ enter(obj.next(), direction, distance, number, time, delay) } }, delay) } // css3 y浣嶇щ if(direction == "y"){ obj.stop().transition({ y : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() + 1 <= number){ enter(obj.next(), direction, distance, number, time, delay) } }, delay) } } // 鍥剧墖鍔犺浇 璋冪敤鏂规硶 // _preloadimg([ // 鍥剧墖璺緞 // ],function(){ // }) function _preloadimg(b,e){var c=0,a={},d=0;for(src in b){d++}for(src in b){a[src]=new image();a[src].onload=function(){if(++c>=d){e(a)}};a[src].src=b[src]}};