2
0
mirror of https://github.com/tenrok/vue2-datepicker.git synced 2026-06-17 18:50:36 +03:00

fix: compatible with mobile click events

This commit is contained in:
mengxiong10
2019-11-10 18:53:14 +08:00
parent b161ff7593
commit 73ef846a86
2 changed files with 5 additions and 4 deletions
+2 -2
View File
@@ -7,7 +7,7 @@
disabled: disabled,
}"
>
<div v-if="!inline" class="mx-input-wrapper" @click="openPopup">
<div v-if="!inline" class="mx-input-wrapper" @mousedown="openPopup" @touchstart="openPopup">
<input
ref="input"
v-bind="{ name: 'date', type: 'text', autocomplete: 'off', ...inputAttr }"
@@ -22,7 +22,7 @@
@input="handleInputInput"
@change="handleInputChange"
/>
<i v-if="showClearIcon" class="mx-icon-clear" @click.stop="handleClear">
<i v-if="showClearIcon" class="mx-icon-clear" @mousedown.stop="handleClear">
<slot name="icon-clear">
<icon-close></icon-close>
</slot>
+3 -2
View File
@@ -42,8 +42,9 @@ export default {
if (this.appendToBody) {
document.body.appendChild(this.$el);
}
this._clickoutEvent = 'ontouchend' in document ? 'touchstart' : 'mousedown';
document.addEventListener('mousedown', this.handleClickOutside);
document.addEventListener(this._clickoutEvent, this.handleClickOutside);
// change the popup position when resize or scroll
const relativeElement = this.$parent.$el;
@@ -60,7 +61,7 @@ export default {
this.$el.parentNode.removeChild(this.$el);
}
document.removeEventListener('mousedown', this.handleClickOutside);
document.removeEventListener(this._clickoutEvent, this.handleClickOutside);
this._scrollParent.removeEventListener('scroll', this._displayPopup);
window.removeEventListener('resize', this._displayPopup);