InputNumber: fix touch one click trigger twice on the window touch pad (#21760)

* fix touch one click trigger twice on the window touch pad

* change var bane
pull/22383/head
mrsai 2023-02-09 20:33:34 +08:00 committed by GitHub
parent 614422011c
commit 027291907c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

1
.gitignore vendored
View File

@ -22,3 +22,4 @@ coverage
waiter.config.js waiter.config.js
build/bin/algolia-key.js build/bin/algolia-key.js
.envrc .envrc
.history/

View File

@ -1,12 +1,14 @@
import { once, on } from 'element-ui/src/utils/dom'; import { once, on } from 'element-ui/src/utils/dom';
import { isMac } from 'element-ui/src/utils/util';
export default { export default {
bind(el, binding, vnode) { bind(el, binding, vnode) {
let interval = null; let interval = null;
let startTime; let startTime;
const maxIntervals = isMac() ? 100 : 300;
const handler = () => vnode.context[binding.expression].apply(); const handler = () => vnode.context[binding.expression].apply();
const clear = () => { const clear = () => {
if (Date.now() - startTime < 100) { if (Date.now() - startTime < maxIntervals) {
handler(); handler();
} }
clearInterval(interval); clearInterval(interval);
@ -18,7 +20,7 @@ export default {
startTime = Date.now(); startTime = Date.now();
once(document, 'mouseup', clear); once(document, 'mouseup', clear);
clearInterval(interval); clearInterval(interval);
interval = setInterval(handler, 100); interval = setInterval(handler, maxIntervals);
}); });
} }
}; };

View File

@ -239,3 +239,7 @@ export function objToArray(obj) {
} }
return isEmpty(obj) ? [] : [obj]; return isEmpty(obj) ? [] : [obj];
} }
export const isMac = function() {
return !Vue.prototype.$isServer && /macintosh|mac os x/i.test(navigator.userAgent);
};