diff --git a/.gitignore b/.gitignore index a9b3749c..e9a3f06e 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ coverage waiter.config.js build/bin/algolia-key.js .envrc +.history/ \ No newline at end of file diff --git a/src/directives/repeat-click.js b/src/directives/repeat-click.js index 9aaef3ad..ae7ad977 100644 --- a/src/directives/repeat-click.js +++ b/src/directives/repeat-click.js @@ -1,12 +1,14 @@ import { once, on } from 'element-ui/src/utils/dom'; +import { isMac } from 'element-ui/src/utils/util'; export default { bind(el, binding, vnode) { let interval = null; let startTime; + const maxIntervals = isMac() ? 100 : 300; const handler = () => vnode.context[binding.expression].apply(); const clear = () => { - if (Date.now() - startTime < 100) { + if (Date.now() - startTime < maxIntervals) { handler(); } clearInterval(interval); @@ -18,7 +20,7 @@ export default { startTime = Date.now(); once(document, 'mouseup', clear); clearInterval(interval); - interval = setInterval(handler, 100); + interval = setInterval(handler, maxIntervals); }); } }; diff --git a/src/utils/util.js b/src/utils/util.js index eab95814..a9634d7a 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -239,3 +239,7 @@ export function objToArray(obj) { } return isEmpty(obj) ? [] : [obj]; } + +export const isMac = function() { + return !Vue.prototype.$isServer && /macintosh|mac os x/i.test(navigator.userAgent); +};