distance to top
+ // adjust tab position
onScroll() {
- this.fixed = scrollUtils.getScrollTop(this.scrollEl) > scrollUtils.getElementTop(this.$el);
+ const scrollTop = scrollUtils.getScrollTop(this.scrollEl);
+ const elTopToPageTop = scrollUtils.getElementTop(this.$el);
+ const elBottomToPageTop = elTopToPageTop + this.$el.offsetHeight - this.$refs.nav.offsetHeight;
+ if (scrollTop > elBottomToPageTop) {
+ this.position = 'content-bottom';
+ } else if (scrollTop > elTopToPageTop) {
+ this.position = 'page-top';
+ } else {
+ this.position = 'content-top';
+ }
},
// update nav bar style
diff --git a/packages/vant-css/src/field.css b/packages/vant-css/src/field.css
index 1178c9a57..956804408 100644
--- a/packages/vant-css/src/field.css
+++ b/packages/vant-css/src/field.css
@@ -85,6 +85,10 @@
display: block;
width: 100%;
resize: none;
+
+ &[disabled] {
+ background-color: transparent;
+ }
}
&__icon {
diff --git a/packages/vant-css/src/tab.css b/packages/vant-css/src/tab.css
index 7285c3d42..323c14d4b 100644
--- a/packages/vant-css/src/tab.css
+++ b/packages/vant-css/src/tab.css
@@ -7,10 +7,27 @@ $van-tabs-card-height: 28px;
.van-tabs {
position: relative;
+ &__wrap {
+ top: 0;
+ left: 0;
+ right: 0;
+ z-index: 1;
+ position: absolute;
+
+ &--page-top {
+ position: fixed;
+ }
+
+ &--content-bottom {
+ top: auto;
+ bottom: 0;
+ }
+ }
+
&__nav {
display: flex;
- position: relative;
user-select: none;
+ position: relative;
background-color: $white;
&--line {
@@ -49,13 +66,13 @@ $van-tabs-card-height: 28px;
background-color: $red;
}
- &--scrollbale {
+ &--scrollable {
.van-tab {
flex: 0 0 22%;
}
.van-tabs__nav {
- overflow-y: auto;
+ overflow-x: auto;
-webkit-overflow-scrolling: touch;
&::-webkit-scrollbar {
@@ -65,21 +82,12 @@ $van-tabs-card-height: 28px;
}
}
- &--fixed {
- .van-tabs__wrap {
- top: 0;
- left: 0;
- right: 0;
- position: fixed;
- }
+ &--line {
+ padding-top: $van-tabs-line-height;
+ }
- &.van-tabs--line {
- padding-top: $van-tabs-line-height;
- }
-
- &.van-tabs--card {
- padding-top: $van-tabs-card-height;
- }
+ &--card {
+ padding-top: $van-tabs-card-height;
}
}
diff --git a/test/unit/specs/tabs.spec.js b/test/unit/specs/tabs.spec.js
index 5160c2e68..7dacb080f 100644
--- a/test/unit/specs/tabs.spec.js
+++ b/test/unit/specs/tabs.spec.js
@@ -125,7 +125,7 @@ describe('Tabs', () => {
wrapper.vm.sticky = false;
setTimeout(() => {
- expect(wrapper.vm.$children[0].fixed).to.be.false;
+ expect(wrapper.vm.$children[0].position).to.equal('content-top');
done();
}, 30);
});