[Improvement] Tab: scroll to corrent position when sticky & tab change (#389)

This commit is contained in:
neverland
2017-12-07 15:28:27 +08:00
committed by GitHub
parent 0d64d5ea49
commit d6c6e9d742
3 changed files with 16 additions and 7 deletions
+11 -3
View File
@@ -79,6 +79,11 @@ export default {
curActive() {
this.scrollIntoView();
this.setNavBar();
// scroll to correct position
if (this.position === 'page-top' || this.position === 'content-bottom') {
scrollUtils.setScrollTop(this.scrollEl, scrollUtils.getElementTop(this.$el));
}
},
sticky(isSticky) {
@@ -90,9 +95,12 @@ export default {
this.correctActive(this.active);
this.setNavBar();
if (this.sticky) {
this.scrollHandler(true);
}
this.$nextTick(() => {
if (this.sticky) {
this.scrollHandler(true);
}
this.scrollIntoView();
});
},
beforeDestroy() {
+2 -1
View File
@@ -73,11 +73,12 @@ $van-tabs-card-height: 28px;
.van-tabs__nav {
overflow-x: auto;
overflow-y: hidden;
-webkit-overflow-scrolling: touch;
&::-webkit-scrollbar {
display: none;
background-color: transparent;
background: transparent;
}
}
}