mirror of https://github.com/ElemeFE/element
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 banepull/22383/head
parent
614422011c
commit
027291907c
|
@ -22,3 +22,4 @@ coverage
|
||||||
waiter.config.js
|
waiter.config.js
|
||||||
build/bin/algolia-key.js
|
build/bin/algolia-key.js
|
||||||
.envrc
|
.envrc
|
||||||
|
.history/
|
|
@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -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);
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue