mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bugfix] Tab: scroll position after activated (#1512)
This commit is contained in:
parent
b7b2ad9ffc
commit
191f983e19
@ -126,13 +126,14 @@ export default create({
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.handlers(true);
|
||||
this.scrollIntoView();
|
||||
this.scrollIntoView(true);
|
||||
});
|
||||
},
|
||||
|
||||
activated() {
|
||||
this.$nextTick(() => {
|
||||
this.handlers(true);
|
||||
this.scrollIntoView(true);
|
||||
});
|
||||
},
|
||||
|
||||
@ -258,7 +259,7 @@ export default create({
|
||||
},
|
||||
|
||||
// scroll active tab into view
|
||||
scrollIntoView() {
|
||||
scrollIntoView(immediate) {
|
||||
if (!this.scrollable || !this.$refs.tabs) {
|
||||
return;
|
||||
}
|
||||
@ -268,11 +269,16 @@ export default create({
|
||||
const { scrollLeft, offsetWidth: navWidth } = nav;
|
||||
const { offsetLeft, offsetWidth: tabWidth } = tab;
|
||||
|
||||
this.scrollTo(nav, scrollLeft, offsetLeft - (navWidth - tabWidth) / 2);
|
||||
this.scrollTo(nav, scrollLeft, offsetLeft - (navWidth - tabWidth) / 2, immediate);
|
||||
},
|
||||
|
||||
// animate the scrollLeft of nav
|
||||
scrollTo(el, from, to) {
|
||||
scrollTo(el, from, to, immediate) {
|
||||
if (immediate) {
|
||||
el.scrollLeft += to - from;
|
||||
return;
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
const frames = Math.round(this.duration * 1000 / 16);
|
||||
const animate = () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user