Git Product home page Git Product logo

Comments (10)

satya164 avatar satya164 commented on March 29, 2024 3

A not-so-practical workaround to avoid this animation issue would then be to somehow pass the tab navigator's width and height before mount

We don't need that. The one frame delay is only for things like indicator which absolutely need the width before rendering. Tab view knows how to handle the layout before measurement is done, so that there is no delay. There were some missing styles in the scrollview based pager that iOS uses, which prevented it from working properly. I just pushed an update with fixed styles.

When testing, please also use react-native-debugger to make sure the embedded chrome debugger doesnt hide the issue

Debuggers often change the behaviour. So it's better not to use any debuggers while testing an issue.

from react-navigation.

hilkeheremans avatar hilkeheremans commented on March 29, 2024 1

This is still an issue on latest master as of this post. When testing, please also use react-native-debugger to make sure the embedded chrome debugger doesnt hide the issue.

To reproduce, use a TabNavigator as follows:

export const TestTabAnim = TabNavigator({
        splash: {
            screen: () => (<View style={{ flex: 1, backgroundColor: 'red' }}><Text>Tab 1</Text></View>)
        },
        login: {
            screen: () => (<View style={{ flex: 1, backgroundColor: 'blue' }}><Text>Tab 1</Text></View>)
        },
        home: {
            screen: () => (<View style={{ flex: 1, backgroundColor: 'purple' }}><Text>Tab 1</Text></View>)
        }
    })

I have tracked down the root cause, and it lies within the react-native-tab-view dependency. More specifically, when an AnimatedTabView tries to mount initially, it has no knowledge of the actual dimensions it should render in, and thus has no idea of what to animate to. In order to circumvent this, the TabViewTransitioner component in react-native-tab-view seems to use onLayout to immediately change the animation target to the actual width and height of the view (https://github.com/react-native-community/react-native-tab-view/blob/master/src/TabViewTransitioner.js#L110). This causes a "one frame delay in rendering", which is also what you notice visually.

A not-so-practical workaround to avoid this animation issue would then be to somehow pass the tab navigator's width and height before mount. I tested this hypothesis by directly passing a hardcoded initialLayout={{ height: <height>, width: <width> }} prop to the AnimatedTabView from TabView in react-native-navigation (ie here: https://github.com/react-community/react-navigation/blob/master/src/views/TabView/TabView.js#L184). This resolves the issue albeit not in a very practical way :-).

@satya164 Seems like you are 'the man to talk to' re react-native-tab-view -- any further insights? Thanks!

from react-navigation.

satya164 avatar satya164 commented on March 29, 2024

I think you need to set flex: 1 on your view.

from react-navigation.

wenbinf avatar wenbinf commented on March 29, 2024

Thanks @satya164 , but now it becomes this:

jan-27-2017 14-08-16

I added "flex: 1"

class HomeScreen extends React.Component {
    render() {
        return <View style={{flex: 1, flexDirection:'row', backgroundColor: 'red', height: 300,
            justifyContent:'flex-end', paddingTop: 30}}>
            <Text>Hello, Navigation!</Text>
        </View>
    }
}

btw, StackNavigator and DrawerNavigator don't have this issue. It's only TabNavigator.

from react-navigation.

satya164 avatar satya164 commented on March 29, 2024

So seems it only happens when you've flexDirection: row. For example, the following works fine,

class HomeScreen extends React.Component {
  render() {
    return (
      <View>
        <View
          style={{
            flexDirection: 'row',
            backgroundColor: 'red',
            height: 300,
            justifyContent: 'flex-end',
            paddingTop: 30,
          }}
        >
          <Text>Hello, Navigation!</Text>
        </View>
      </View>
    );
  }
}

from react-navigation.

wenbinf avatar wenbinf commented on March 29, 2024

hmm ... I ran your code snippet, but it still doesn't work.

The version that I'm using is "react-navigation": "^1.0.0-beta.1".

Let me dig more ...

from react-navigation.

satya164 avatar satya164 commented on March 29, 2024

@wenbinf hmm. I just tested this on simulator and couldn't reproduce the issue anymore.

from react-navigation.

wenbinf avatar wenbinf commented on March 29, 2024

For the record, this was the environment that I tested

  • node v7.2.1
  • iOS Simulator: iPhone 6 + iOS 8.4 / iOS 10, iPhone 7 + iOS 10.2
  • real iphone 6 + iOS 10.2
  • "react-navigation": "^1.0.0-beta.1"
  • "react-native": "0.40.0",

Just in case someone on the Internet encounters the same problem :)

from react-navigation.

hilkeheremans avatar hilkeheremans commented on March 29, 2024

Thanks!

from react-navigation.

wenbinf avatar wenbinf commented on March 29, 2024
npm install --save react-community/react-navigation
node_modules/react-native/packager/packager.sh --reset-cache

Then it works!

Thanks a lot! @satya164

from react-navigation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.