React-native-tab-view: Get position of the tab-view to animate a view outside of the view hierarchy of the scene

Created on 22 May 2019  路  7Comments  路  Source: satya164/react-native-tab-view

Question

In version 1 of react-native-tab-view it was possible to access the position-value by adding a custom pager like that:

_renderPager = props => {
    return (
        <View style={{ flex: 1}}>
            <Pager {...props} GestureHandler={GestureHandler} swipeMinDeltaX={30} />
            <OnlineArchiveControl {...props} />
        </View>
    )
};

In the snippet above the OnlineArchiveControl can interpolate the position to transform the yvalue. You can see the functionality in the attached GIF.

Is a similar implementation possible in v2 of this great library?

Der Postillon_2019-05-22-00-27-29

Most helpful comment

Hi,

just a comment for anyone looking to achieve an animation based on the position.

react-native-tab-view use internally https://github.com/kmagiera/react-native-reanimated to do animation.

This mean that the position you provide to you TabView should be an react-native-reanimated Animated.Value, not a regular react-native Animated.Value

Here an expo showing the basic https://snack.expo.io/HJ8Fj1p04

All 7 comments

It's not currently possible to get the position outside the tab view. But I'm thinking about accepting a reanimated value which we can keep updated with the position

Hi @satya164, thank you for your hyper fast response!

But I'm thinking about accepting a reanimated value which we can keep updated with the position

This would be awesome. When could I expect this functionality will be added to this library?

Just sent a PR #782

Thank you very much!
It works as expected!

Hi,

just a comment for anyone looking to achieve an animation based on the position.

react-native-tab-view use internally https://github.com/kmagiera/react-native-reanimated to do animation.

This mean that the position you provide to you TabView should be an react-native-reanimated Animated.Value, not a regular react-native Animated.Value

Here an expo showing the basic https://snack.expo.io/HJ8Fj1p04

@maxired thanks

Is there any way to use position with reanimated v2?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

satya164 picture satya164  路  3Comments

hyochan35 picture hyochan35  路  3Comments

glennvgastel picture glennvgastel  路  3Comments

ios-dev-newbie picture ios-dev-newbie  路  3Comments

lubomyr picture lubomyr  路  3Comments