mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-11-29 10:47:36 +08:00
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
This commit is contained in:
parent
614422011c
commit
027291907c
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,3 +22,4 @@ coverage
|
||||
waiter.config.js
|
||||
build/bin/algolia-key.js
|
||||
.envrc
|
||||
.history/
|
@ -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);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -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);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user