Javascript 反应本机:在NavigationExperimental中禁用场景转换

Javascript 反应本机:在NavigationExperimental中禁用场景转换,javascript,reactjs,animation,react-native,navigation,Javascript,Reactjs,Animation,React Native,Navigation,我开始使用NavigationExperimental的原因是为了让我能够更全面地控制导航和渲染 但是,我无法找到一种方法来删除场景变换上的默认动画。我只想直接跳到下一个屏幕 import React, { Component } from 'react'; import { View, NavigationExperimental, } from 'react-native'; const { CardStack: NavigationCardStack, StateUtil

我开始使用NavigationExperimental的原因是为了让我能够更全面地控制导航和渲染

但是,我无法找到一种方法来删除场景变换上的默认动画。我只想直接跳到下一个屏幕

import React, { Component } from 'react';
import {
  View,
  NavigationExperimental,
} from 'react-native';

const {
  CardStack: NavigationCardStack,
  StateUtils: NavigationStateUtils
} = NavigationExperimental;

class Navigation extends React.Component {

  constructor(props, context) {
    super(props, context);

    this._onPushRoute = this.props.onNavigationChange.bind(null, 'push');
    this._onPopRoute = this.props.onNavigationChange.bind(null, 'pop');

    this._renderScene = this._renderScene.bind(this);
  }

  // Now we finally get to use the `NavigationCardStack` to render the scenes.
  render() {
    return (
      <NavigationCardStack
        onNavigateBack={this._onPopRoute}
        navigationState={this.props.navigationState}
        renderScene={(sceneProps) => {
          return this._renderScene(sceneProps);
        }}
        style={{flex:1}}
      />
    );
  }

  // Render a scene for route.
  // The detailed spec of `sceneProps` is defined at `NavigationTypeDefinition`
  // as type `NavigationSceneRendererProps`.
  // Here you could choose to render a different component for each route, but
  // we'll keep it simple.
  _renderScene(sceneProps) {
    return (
      <View
        route={sceneProps.scene.route}
        onPushRoute={this._onPushRoute}
        onPopRoute={this._onPopRoute}
        onExit={this.props.onExit}
        style={{flex:1}}
      >
        <sceneProps.component />
      </View>
    );
  }
}

module.exports = Navigation
import React,{Component}来自'React';
进口{
看法
导航实验,
}从“反应本机”;
常数{
CardStack:NavigationCardStack,
StateUtils:导航StateUtils
}=导航实验;
类导航扩展了React.Component{
构造函数(道具、上下文){
超级(道具、背景);
this._onPushRoute=this.props.onNavigationChange.bind(null,'push');
this._onPopRoute=this.props.onNavigationChange.bind(null,'pop');
this.\u renderScene=this.\u renderScene.bind(this);
}
//现在我们终于可以使用“NavigationCardStack”来渲染场景了。
render(){
返回(
{
返回此。\u renderScene(sceneProps);
}}
style={{flex:1}}
/>
);
}
//为路线渲染场景。
//“sceneProps”的详细规范在“NavigationTypeDefinition”中定义`
//类型为“NavigationScenerEnderOps”。
//在这里,您可以选择为每条管线渲染不同的组件,但是
//我们会保持简单。
_渲染场景(场景投影){
返回(
);
}
}
module.exports=导航

坏消息转换在
CardStack
中进行编码。已经提供了,但被放弃了,没有合并。好消息是,您可以复制和修改它。可以在中找到使用导航传递器的示例

EDITLook like
cardStyleInterpolator
属性是3周前添加的,将在React Native 0.41中发布。因此,您可以将新版本的
NavigationCardStack.js
文件复制到项目中并使用它