// 榛樿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) }) } function set_font() { // 璁$畻銆佽浆鎹㈠竷灞€鍗曚綅 var html = document.getelementsbytagname('html')[0]; var designfontsize = 100, designwidth = 1920; function setfontsize() { var winwidth = document.documentelement.getboundingclientrect().width; if(winwidth>=770){ designwidth = 1920; }else{ designwidth = 750; } var fontsize = winwidth / designwidth * designfontsize; html.style.fontsize = fontsize + 'px'; } setfontsize(); window.addeventlistener('resize', function () { setfontsize(); }); return this; } set_font() // 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"); } // 瑙嗛鍏ㄥ睆 / 瑙嗛鍏呮弧鏁翠釜鐖剁骇 (video鑾峰彇瀹介珮鏈夐棶棰? function videofull(obj, width, height){ var $video = obj function resizebg() { $video.attr("width", "").attr("height", "").attr("style", "") var boxr = $('.top-video').outerwidth() / $('.top-video').outerheight(), objr = width / height; if( objr < boxr ) { $video.attr("width", "100%") var videoheight = $video.width() / objr var top = - (videoheight - $('.top-video').outerheight()) / 2 > 0 ? 0 : - (videoheight - $('.top-video').outerheight()) / 2 $video.css("margin-top", top); }else{ $video.attr("height", "100%") var videowidth = $video.height() * objr var left = - (videowidth - $('.top-video').outerwidth()) / 2 > 0 ? 0 : - (videowidth - $('.top-video').outerwidth()) / 2 $video.css("margin-left", left); } } $(window).resize(resizebg).trigger("resize"); } // 鏍囩杩涘満鏁堟灉 // 鐢ㄤ簬澶氬钩绾ф爣绛句緷娆¤浇鍏?榛樿鏍囩鍏锋湁position灞炴€у強opacuty: 0; // direction 浠庡摢涓柟鍚戣繘鍏? // distance 杩涘叆鍒版寚瀹氳窛绂? // number 骞崇骇鏍囩鐨勪釜鏁? // time 杩涘満鍔ㄧ敾鐨勬椂闂? // delay 涓嬩竴鏍囩鐨勫欢杩? // callback 鍥炶皟鍑芥暟 function enter(obj, direction, distance, number, time, delay, callback) { // 浠庡乏寰€鍙筹紝distance > 0 if(direction == "left"){ obj.stop().animate({ left : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() != -1){ enter(obj.next(), direction, distance, number, time, delay, callback) }else{ settimeout(function(){ callback = callback || function(){}; callback (); return }, time - delay) } }, delay) } // 浠庝笂寰€涓嬶紝distance > 0 if(direction == "top"){ obj.stop().animate({ top : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() != -1){ enter(obj.next(), direction, distance, number, time, delay, callback) }else{ settimeout(function(){ callback = callback || function(){}; callback (); return }, time - delay) } }, delay) } // css3 x浣嶇щ if(direction == "x"){ obj.stop().transition({ x : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() != -1){ enter(obj.next(), direction, distance, number, time, delay, callback) }else{ settimeout(function(){ callback = callback || function(){}; callback (); return }, time - delay) } }, delay) } // css3 y浣嶇щ if(direction == "y"){ obj.stop().transition({ y : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() != -1){ enter(obj.next(), direction, distance, number, time, delay, callback) }else{ settimeout(function(){ callback = callback || function(){}; callback (); return }, 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]}}; /*********************************************************************************************/ // jquery(window).load(function(){ // // jquery('.article-block').delay(300).scrollclass(); // }); /*********************************************************************************************/ // 娓愬叆鏁堟灉 /*********************************************************************************************/ (function(jquery){ $.fn.scrollclass = function(config){ var defaults = {}; var config = jquery.extend(defaults, config); var target = this; function addaction(){ var length = target.length; for(var i=0; i