Compare commits

..

No commits in common. "e12ad16e375d84b4f51aacfd701df225edede37e" and "bafbafe887a386132ab01ef786ab9d3e28686455" have entirely different histories.

8 changed files with 40 additions and 75 deletions

View File

@ -93,11 +93,13 @@ VantComponent({
const { data } = this;
const val = this.correctValue(data.value);
const isEqual = val === data.innerValue;
this.updateColumnValue(val).then(() => {
if (!isEqual) {
if (!isEqual) {
this.updateColumnValue(val).then(() => {
this.$emit('input', val);
}
});
});
} else {
this.updateColumns();
}
},
getPicker() {
if (this.picker == null) {

35
dist/tabs/index.js vendored
View File

@ -43,9 +43,6 @@ VantComponent({
type: null,
value: 0,
observer(name) {
if (!this.skipInit) {
this.skipInit = true;
}
if (name !== this.getCurrentName()) {
this.setCurrentIndexByName(name);
}
@ -92,7 +89,6 @@ VantComponent({
currentIndex: 0,
container: null,
skipTransition: true,
scrollWithAnimation: false,
lineOffsetLeft: 0,
},
mounted() {
@ -100,10 +96,8 @@ VantComponent({
this.setData({
container: () => this.createSelectorQuery().select('.van-tabs'),
});
if (!this.skipInit) {
this.resize();
this.scrollIntoView();
}
this.resize(true);
this.scrollIntoView();
});
},
methods: {
@ -172,11 +166,9 @@ VantComponent({
}
const shouldEmitChange = data.currentIndex !== null;
this.setData({ currentIndex });
requestAnimationFrame(() => {
nextTick(() => {
this.resize();
this.scrollIntoView();
});
nextTick(() => {
this.trigger('input');
if (shouldEmitChange) {
this.trigger('change');
@ -189,11 +181,11 @@ VantComponent({
return activeTab.getComputedName();
}
},
resize() {
resize(skipTransition = false) {
if (this.data.type !== 'line') {
return;
}
const { currentIndex, ellipsis, skipTransition } = this.data;
const { currentIndex, ellipsis } = this.data;
Promise.all([
getAllRect(this, '.van-tab'),
getRect(this, '.van-tabs__line'),
@ -207,17 +199,15 @@ VantComponent({
.reduce((prev, curr) => prev + curr.width, 0);
lineOffsetLeft +=
(rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8);
this.setData({ lineOffsetLeft });
if (skipTransition) {
nextTick(() => {
this.setData({ skipTransition: false });
});
}
this.setData({
lineOffsetLeft,
skipTransition,
});
});
},
// scroll active tab into view
scrollIntoView() {
const { currentIndex, scrollable, scrollWithAnimation } = this.data;
const { currentIndex, scrollable } = this.data;
if (!scrollable) {
return;
}
@ -232,11 +222,6 @@ VantComponent({
this.setData({
scrollLeft: offsetLeft - (navRect.width - tabRect.width) / 2,
});
if (!scrollWithAnimation) {
nextTick(() => {
this.setData({ scrollWithAnimation: true });
});
}
});
},
onTouchScroll(event) {

View File

@ -14,7 +14,7 @@
<scroll-view
scroll-x="{{ scrollable }}"
scroll-with-animation="{{ scrollWithAnimation }}"
scroll-with-animation
scroll-left="{{ scrollLeft }}"
class="{{ utils.bem('tabs__scroll', [type]) }}"
style="{{ color ? 'border-color: ' + color : '' }}"

View File

@ -1,18 +1,8 @@
# 更新日志
### [1.6.9](https://github.com/youzan/vant-weapp/tree/v1.6.9)
### [1.6.9-beta.2](https://github.com/youzan/vant-weapp/compare/v1.6.8...v1.6.9-beta.2) (2021-05-22)
`2021-06-06`
**Bug Fixes**
- DatetimePicker: 修复 动态设置 min-hour min-date 显示不正确 [#4245](https://github.com/youzan/vant-weapp/issues/4245)
- Tabs: 修复 tab数量较多时滚动距离不正确 [#4202](https://github.com/youzan/vant-weapp/issues/4202)
- Uploader: 修复 demo 中 beforeRead 报错 [#4235](https://github.com/youzan/vant-weapp/issues/4235)
### [1.6.9-beta.2](https://github.com/youzan/vant-weapp/tree/v1.6.9-beta.2)
`2021-05-22`
`2021-05-23`
**Bug Fixes**

View File

@ -120,11 +120,13 @@ component_1.VantComponent({
var data = this.data;
var val = this.correctValue(data.value);
var isEqual = val === data.innerValue;
this.updateColumnValue(val).then(function () {
if (!isEqual) {
if (!isEqual) {
this.updateColumnValue(val).then(function () {
_this.$emit('input', val);
}
});
});
} else {
this.updateColumns();
}
},
getPicker: function () {
if (this.picker == null) {

View File

@ -40,9 +40,6 @@ component_1.VantComponent({
type: null,
value: 0,
observer: function (name) {
if (!this.skipInit) {
this.skipInit = true;
}
if (name !== this.getCurrentName()) {
this.setCurrentIndexByName(name);
}
@ -89,7 +86,6 @@ component_1.VantComponent({
currentIndex: 0,
container: null,
skipTransition: true,
scrollWithAnimation: false,
lineOffsetLeft: 0,
},
mounted: function () {
@ -100,10 +96,8 @@ component_1.VantComponent({
return _this.createSelectorQuery().select('.van-tabs');
},
});
if (!_this.skipInit) {
_this.resize();
_this.scrollIntoView();
}
_this.resize(true);
_this.scrollIntoView();
});
},
methods: {
@ -183,11 +177,9 @@ component_1.VantComponent({
}
var shouldEmitChange = data.currentIndex !== null;
this.setData({ currentIndex: currentIndex });
utils_1.requestAnimationFrame(function () {
utils_1.nextTick(function () {
_this.resize();
_this.scrollIntoView();
});
utils_1.nextTick(function () {
_this.trigger('input');
if (shouldEmitChange) {
_this.trigger('change');
@ -200,15 +192,17 @@ component_1.VantComponent({
return activeTab.getComputedName();
}
},
resize: function () {
resize: function (skipTransition) {
var _this = this;
if (skipTransition === void 0) {
skipTransition = false;
}
if (this.data.type !== 'line') {
return;
}
var _a = this.data,
currentIndex = _a.currentIndex,
ellipsis = _a.ellipsis,
skipTransition = _a.skipTransition;
ellipsis = _a.ellipsis;
Promise.all([
utils_1.getAllRect(this, '.van-tab'),
utils_1.getRect(this, '.van-tabs__line'),
@ -227,12 +221,10 @@ component_1.VantComponent({
}, 0);
lineOffsetLeft +=
(rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8);
_this.setData({ lineOffsetLeft: lineOffsetLeft });
if (skipTransition) {
utils_1.nextTick(function () {
_this.setData({ skipTransition: false });
});
}
_this.setData({
lineOffsetLeft: lineOffsetLeft,
skipTransition: skipTransition,
});
});
},
// scroll active tab into view
@ -240,8 +232,7 @@ component_1.VantComponent({
var _this = this;
var _a = this.data,
currentIndex = _a.currentIndex,
scrollable = _a.scrollable,
scrollWithAnimation = _a.scrollWithAnimation;
scrollable = _a.scrollable;
if (!scrollable) {
return;
}
@ -260,11 +251,6 @@ component_1.VantComponent({
_this.setData({
scrollLeft: offsetLeft - (navRect.width - tabRect.width) / 2,
});
if (!scrollWithAnimation) {
utils_1.nextTick(function () {
_this.setData({ scrollWithAnimation: true });
});
}
});
},
onTouchScroll: function (event) {

View File

@ -14,7 +14,7 @@
<scroll-view
scroll-x="{{ scrollable }}"
scroll-with-animation="{{ scrollWithAnimation }}"
scroll-with-animation
scroll-left="{{ scrollLeft }}"
class="{{ utils.bem('tabs__scroll', [type]) }}"
style="{{ color ? 'border-color: ' + color : '' }}"

View File

@ -1,6 +1,6 @@
{
"name": "@vant/weapp",
"version": "1.6.9",
"version": "1.6.9-beta.2",
"author": "youzan",
"license": "MIT",
"miniprogram": "lib",