Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed: 解决tab-container在tab页较长时,纵向页面移动与横向tab切换容易造成页面错乱的问题。 #1531

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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