diff --git a/source/css/_layout/mobile-sidebar.styl b/source/css/_layout/mobile-sidebar.styl index fd10359..ac26c28 100644 --- a/source/css/_layout/mobile-sidebar.styl +++ b/source/css/_layout/mobile-sidebar.styl @@ -152,7 +152,7 @@ transform: translateX(-254px) opacity: 1 -// pc界面打開mobile-menus需關閉sidebar + // pc界面打開mobile-menus需關閉sidebar #sidebar left: -300px !important diff --git a/source/js/utils.js b/source/js/utils.js index e5010dc..57e15c2 100644 --- a/source/js/utils.js +++ b/source/js/utils.js @@ -1,3 +1,19 @@ +function debounce(func, wait, immediate) { + var timeout + return function () { + var context = this + var args = arguments + var later = function () { + timeout = null + if (!immediate) func.apply(context, args) + } + var callNow = immediate && !timeout + clearTimeout(timeout) + timeout = setTimeout(later, wait) + if (callNow) func.apply(context, args) + } +}; + function throttle(func, wait, options) { var timeout, context, args, result; var previous = 0; @@ -81,6 +97,7 @@ function snackbarShow(text, showAction, duration) { } +window.debounce = debounce window.throttle = throttle