fix(Tabs): skip initial animation

This commit is contained in:
chenjiahan 2020-11-01 09:57:42 +08:00
parent 2d2f0d8ad4
commit 49e87756c7

View File

@ -157,14 +157,6 @@ export default createComponent({
scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
};
const init = () => {
nextTick(() => {
state.inited = true;
tabHeight = getVisibleHeight(wrapRef.value);
scrollIntoView(true);
});
};
// update nav bar style
const setLine = () => {
const shouldAnimate = state.inited;
@ -385,11 +377,13 @@ export default createComponent({
watch(
() => children.length,
() => {
nextTick(() => {
if (state.inited) {
setCurrentIndexByName(props.active || currentName.value);
setLine();
scrollIntoView(true);
});
nextTick(() => {
scrollIntoView(true);
});
}
}
);
@ -408,6 +402,15 @@ export default createComponent({
}
);
const init = () => {
setCurrentIndexByName(props.active || currentName.value);
nextTick(() => {
state.inited = true;
tabHeight = getVisibleHeight(wrapRef.value);
scrollIntoView(true);
});
};
onMounted(init);
onActivated(() => {