[bugfix] ImagePreview offset empty

This commit is contained in:
nrz
2018-05-04 15:22:15 +08:00
committed by neverland
parent 2899a4cb8e
commit af6f7c0d0b
2 changed files with 10 additions and 7 deletions
+6 -3
View File
@@ -7,7 +7,7 @@
@touchend="onTouchEnd"
@touchcancel="onTouchEnd"
>
<swipe :initial-swipe="startPosition">
<swipe :initial-swipe="startPosition" ref="swipe">
<swipe-item v-for="(item, index) in images" :key="index">
<img :class="b('image')" :src="item" >
</swipe-item>
@@ -58,9 +58,12 @@ export default create({
onTouchEnd(event) {
event.preventDefault();
// prevent long tap to close component
const deltaTime = new Date() - this.touchStartTime;
if (deltaTime < 100 && this.offsetX < 20 && this.offsetY < 20) {
const { offsetX, offsetY } = this.$refs.swipe;
// prevent long tap to close component
if (deltaTime < 100 && offsetX < 20 && offsetY < 20) {
this.$emit('input', false);
}
}