// 榛樿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) } } // 鍥剧墖鍔犺浇 璋冪敤鏂规硶 // _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]}};