akveo / react-native-ui-kitten

:boom: React Native UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
https://akveo.github.io/react-native-ui-kitten/
MIT License
10.21k stars 951 forks source link

TabView Animation Jittery #1228

Closed NickTheTurtle closed 3 years ago

NickTheTurtle commented 3 years ago

🐛 Bug Report

Jittery animation with TabView.

To Reproduce

Have a TabView which each contain a SwipeListView from 'react-native-swipe-list-view' with a couple of rows (> 2). Try to go through different pages. With fewer rows, the animation are smoother, so it seems to be rendering very slowly that's the issue

Expected behavior

Fluid animations.

UI Kitten and Eva version

Package Version
@eva-design/eva 2.0.0
@ui-kitten/components 5.0.0

Environment information

System:
    OS: macOS 11.0
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  Binaries:
    Node: 14.5.0 - /usr/local/bin/node
    npm: 6.14.7 - /usr/local/bin/npm
  IDEs:
    Xcode: /undefined - /usr/bin/xcodebuild
NickTheTurtle commented 3 years ago

So I rolled out my own version of ViewPager. It seems like calling both scroll and setSelectedIndex simultaneously causes the scroll to jump. Instead I called scrollTo for the scrollView, and onScroll I set the index. Now the activity indicator still jumps, but it's slightly better I guess.

  <ScrollView
        ref={pageView}
        style={styles.view}
        contentContainerStyle={{width: '200%'}}
        pagingEnabled
        bounces={false}
        horizontal
        onScroll={onPageViewScroll}
        overScrollMode="never"
        disableScrollViewPanResponder
        showsHorizontalScrollIndicator={false}>
        <View style={styles.view}>
         <Tab1 />
        </View>
        <View style={styles.view}>
          <Tab2 />
        </View>
      </ScrollView>

  function goToTab(index) {
    pageView.current.scrollTo({x: windowWidth * index, y: 0, animated: true});
  }

  function onPageViewScroll(event) {
    if (event.nativeEvent.contentOffset.x % windowWidth === 0) {
      setSelectedIndex(event.nativeEvent.contentOffset.x / windowWidth);
    }
  }
artyorsh commented 3 years ago

I guess this issue is could be related to https://github.com/akveo/react-native-ui-kitten/issues/1234 Closing this one.