Compare commits

..

5 Commits

Author SHA1 Message Date
nemo-shen
e12ad16e37 docs(changelog): v1.6.9 2021-06-06 20:47:11 +08:00
nemo-shen
9b5ab4e29c docs(changelog): v1.6.9 2021-06-06 20:41:38 +08:00
nemo-shen
c43fec08a7 docs(changelog): 1.6.9 2021-06-06 20:28:29 +08:00
nemo-shen
0f1aaa59ff build: release 1.6.9 2021-06-06 20:05:48 +08:00
nemo-shen
b649e2226c build: compile 1.6.9 2021-06-06 20:05:42 +08:00
8 changed files with 75 additions and 40 deletions

View File

@ -93,13 +93,11 @@ 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;
if (!isEqual) { this.updateColumnValue(val).then(() => {
this.updateColumnValue(val).then(() => { if (!isEqual) {
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,6 +43,9 @@ 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);
} }
@ -89,6 +92,7 @@ VantComponent({
currentIndex: 0, currentIndex: 0,
container: null, container: null,
skipTransition: true, skipTransition: true,
scrollWithAnimation: false,
lineOffsetLeft: 0, lineOffsetLeft: 0,
}, },
mounted() { mounted() {
@ -96,8 +100,10 @@ VantComponent({
this.setData({ this.setData({
container: () => this.createSelectorQuery().select('.van-tabs'), container: () => this.createSelectorQuery().select('.van-tabs'),
}); });
this.resize(true); if (!this.skipInit) {
this.scrollIntoView(); this.resize();
this.scrollIntoView();
}
}); });
}, },
methods: { methods: {
@ -166,9 +172,11 @@ VantComponent({
} }
const shouldEmitChange = data.currentIndex !== null; const shouldEmitChange = data.currentIndex !== null;
this.setData({ currentIndex }); this.setData({ currentIndex });
nextTick(() => { requestAnimationFrame(() => {
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');
@ -181,11 +189,11 @@ VantComponent({
return activeTab.getComputedName(); return activeTab.getComputedName();
} }
}, },
resize(skipTransition = false) { resize() {
if (this.data.type !== 'line') { if (this.data.type !== 'line') {
return; return;
} }
const { currentIndex, ellipsis } = this.data; const { currentIndex, ellipsis, skipTransition } = this.data;
Promise.all([ Promise.all([
getAllRect(this, '.van-tab'), getAllRect(this, '.van-tab'),
getRect(this, '.van-tabs__line'), getRect(this, '.van-tabs__line'),
@ -199,15 +207,17 @@ 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({ this.setData({ lineOffsetLeft });
lineOffsetLeft, if (skipTransition) {
skipTransition, nextTick(() => {
}); this.setData({ skipTransition: false });
});
}
}); });
}, },
// scroll active tab into view // scroll active tab into view
scrollIntoView() { scrollIntoView() {
const { currentIndex, scrollable } = this.data; const { currentIndex, scrollable, scrollWithAnimation } = this.data;
if (!scrollable) { if (!scrollable) {
return; return;
} }
@ -222,6 +232,11 @@ 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 scroll-with-animation="{{ scrollWithAnimation }}"
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,8 +1,18 @@
# 更新日志 # 更新日志
### [1.6.9-beta.2](https://github.com/youzan/vant-weapp/compare/v1.6.8...v1.6.9-beta.2) (2021-05-22) ### [1.6.9](https://github.com/youzan/vant-weapp/tree/v1.6.9)
`2021-05-23` `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`
**Bug Fixes** **Bug Fixes**

View File

@ -120,13 +120,11 @@ 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;
if (!isEqual) { this.updateColumnValue(val).then(function () {
this.updateColumnValue(val).then(function () { if (!isEqual) {
_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,6 +40,9 @@ 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);
} }
@ -86,6 +89,7 @@ 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 () {
@ -96,8 +100,10 @@ component_1.VantComponent({
return _this.createSelectorQuery().select('.van-tabs'); return _this.createSelectorQuery().select('.van-tabs');
}, },
}); });
_this.resize(true); if (!_this.skipInit) {
_this.scrollIntoView(); _this.resize();
_this.scrollIntoView();
}
}); });
}, },
methods: { methods: {
@ -177,9 +183,11 @@ component_1.VantComponent({
} }
var shouldEmitChange = data.currentIndex !== null; var shouldEmitChange = data.currentIndex !== null;
this.setData({ currentIndex: currentIndex }); this.setData({ currentIndex: currentIndex });
utils_1.nextTick(function () { utils_1.requestAnimationFrame(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');
@ -192,17 +200,15 @@ component_1.VantComponent({
return activeTab.getComputedName(); return activeTab.getComputedName();
} }
}, },
resize: function (skipTransition) { resize: function () {
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'),
@ -221,10 +227,12 @@ 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({ _this.setData({ lineOffsetLeft: lineOffsetLeft });
lineOffsetLeft: lineOffsetLeft, if (skipTransition) {
skipTransition: skipTransition, utils_1.nextTick(function () {
}); _this.setData({ skipTransition: false });
});
}
}); });
}, },
// scroll active tab into view // scroll active tab into view
@ -232,7 +240,8 @@ 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;
} }
@ -251,6 +260,11 @@ 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 scroll-with-animation="{{ scrollWithAnimation }}"
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-beta.2", "version": "1.6.9",
"author": "youzan", "author": "youzan",
"license": "MIT", "license": "MIT",
"miniprogram": "lib", "miniprogram": "lib",