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:
mrsai
2023-02-09 20:33:34 +08:00
committed by GitHub
parent 614422011c
commit 027291907c
3 changed files with 9 additions and 2 deletions

View File

@@ -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);
});
}
};