jmurzy/react-router-native

Swipe from left screen to pop

Closed this issue · 2 comments

I wonder if this is possible? While i am able to drag the left screen edge to the right i don't know how to hook into it so that i can pop(). Can't find any info on this.

Some digging revealed that these changes in StackRouteView kind of do what i'd want:

+    static contextTypes = {
+       router: PropTypes.object.isRequired,
+    };
   // ....
   // .....

  renderTransition(props: NavigationTransitionProps): ReactElement<any> {
   // ...
    const scenes = props.scenes.map(
     scene => this.renderScene({
       ...props,
+       onNavigateBack: () => {
+        requestAnimationFrame((): void => {
+          this.context.router.pop();
+         });
+       },
       scene,
     })
    );

This is very clumsy of course and the animation is jerky. Are there ways to do this proper? :)

Edit: Testing this in Release mode, the animation is not that jerky anymore. :)

Yikes, sorry about this oversight! I must have accidentally removed pan gesture handling when I restored compatibility with recent versions of NavigationExperimental. This used to work in alpha.0. Will push a fix shortly.

🍺