調用Resize 及 sccroll 節流方式 //Resize var globalResizeTimer = null; $(window).on('load resize',function() { if(globalResizeTimer !== null) { window.clearTimeout(globalResizeTimer); } globalResizeTimer = window.setTimeout(function() { var $win = $(window), $winW = $win.width(); if($winW <= 768){ $('.calendar-title-mobile').sticky({topSpacing:0}); } },50); }); // scroll var globalScrollTimer = null, $goTop = $('#goTop'); $(window).on('load scroll',function() { if(globalScrollTimer !== null) { window.clearTimeout(globalScrollTimer); } globalScrollTimer = window.setTimeout(function() { var $win = $(window), scrollVal = $win.scrollTop(); scrollVal > 50 ? $goTop.fadeIn() : $goTop.fadeOut() ; },50); });