Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions example/pages/tab-container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<div class="page-tab-container">
<mt-tab-container class="page-tabbar-tab-container" v-model="active" swipeable>
<mt-tab-container-item id="tab-container1">
<mt-cell v-for="n in 10" title="tab-container 1"></mt-cell>
<mt-cell v-for="n in 100" :key="n" title="tab-container 1"></mt-cell>
</mt-tab-container-item>
<mt-tab-container-item id="tab-container2">
<mt-cell v-for="n in 5" title="tab-container 2"></mt-cell>
<mt-cell v-for="n in 5" :key="n" title="tab-container 2"></mt-cell>
</mt-tab-container-item>
<mt-tab-container-item id="tab-container3">
<mt-cell v-for="n in 7" title="tab-container 3"></mt-cell>
<mt-cell v-for="n in 7" :key="n" title="tab-container 3"></mt-cell>
</mt-tab-container-item>
</mt-tab-container>
</div>
Expand Down
8 changes: 7 additions & 1 deletion packages/tab-container/src/tab-container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default {
return {
start: { x: 0, y: 0 },
swiping: false,
verSwipingDuringDragging: false, // vertical swiping
activeItems: [],
pageWidth: 0,
currentActive: this.value
Expand Down Expand Up @@ -126,6 +127,7 @@ export default {

onDrag(evt) {
if (!this.dragging) return;
if (this.verSwipingDuringDragging) return;
let swiping;
const e = evt.changedTouches ? evt.changedTouches[0] : evt;
const offsetTop = e.pageY - this.start.y;
Expand All @@ -134,7 +136,10 @@ export default {
const x = Math.abs(offsetLeft);

swiping = !(x < 5 || (x >= 5 && y >= x * 1.73));
if (!swiping) return;
if (!swiping) {
this.verSwipingDuringDragging = true;
return;
}
evt.preventDefault();

const len = this.$children.length - 1;
Expand All @@ -156,6 +161,7 @@ export default {
},

endDrag() {
this.verSwipingDuringDragging = false;
if (!this.swiping) return;
this.dragging = false;
const direction = this.offsetLeft > 0 ? -1 : 1;
Expand Down