feat(Tab): add swipe animation #1174

This commit is contained in:
chenjiahan
2020-10-03 15:33:21 +08:00
parent 812a35079c
commit 1376d6f3f7
4 changed files with 54 additions and 56 deletions
+5 -3
View File
@@ -91,7 +91,6 @@ export default createComponent({
emits: ['click', 'change', 'scroll', 'disabled', 'rendered', 'update:active'],
setup(props, { emit, slots }) {
let inited;
let tabHeight;
let lockScroll;
let stickyFixed;
@@ -106,6 +105,7 @@ export default createComponent({
const { children, linkChildren } = useChildren(TABS_KEY);
const state = reactive({
inited: false,
position: '',
currentIndex: -1,
lineStyle: {
@@ -159,7 +159,7 @@ export default createComponent({
const init = () => {
nextTick(() => {
inited = true;
state.inited = true;
tabHeight = getVisibleHeight(wrapRef.value);
scrollIntoView(true);
});
@@ -167,7 +167,7 @@ export default createComponent({
// update nav bar style
const setLine = () => {
const shouldAnimate = inited;
const shouldAnimate = state.inited;
nextTick(() => {
const titles = titleRefs.value;
@@ -436,9 +436,11 @@ export default createComponent({
)}
<TabsContent
count={children.length}
inited={state.inited}
animated={props.animated}
duration={props.duration}
swipeable={props.swipeable}
lazyRender={props.lazyRender}
currentIndex={state.currentIndex}
onChange={setCurrentIndex}
>