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 { data } = this;
const val = this.correctValue(data.value); const val = this.correctValue(data.value);
const isEqual = val === data.innerValue; const isEqual = val === data.innerValue;
this.updateColumnValue(val).then(() => { if (!isEqual) {
if (!isEqual) { this.updateColumnValue(val).then(() => {
this.$emit('input', val); this.$emit('input', val);
} });
}); } else {
this.updateColumns();
}
}, },
getPicker() { getPicker() {
if (this.picker == null) { if (this.picker == null) {

35
dist/tabs/index.js vendored
View File

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

View File

@ -14,7 +14,7 @@
<scroll-view <scroll-view
scroll-x="{{ scrollable }}" scroll-x="{{ scrollable }}"
scroll-with-animation="{{ scrollWithAnimation }}" scroll-with-animation
scroll-left="{{ scrollLeft }}" scroll-left="{{ scrollLeft }}"
class="{{ utils.bem('tabs__scroll', [type]) }}" class="{{ utils.bem('tabs__scroll', [type]) }}"
style="{{ color ? 'border-color: ' + color : '' }}" 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` `2021-05-23`
**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`
**Bug Fixes** **Bug Fixes**

View File

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

View File

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

View File

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

View File

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