2017-01-09 27 views
2

原因是,爲什麼我開始使用NavigationExperimental會讓我更全面地控制導航和渲染。React Native:禁用導航實驗中的場景轉換

但是,我無法找到一種方法來刪除場景轉換上的默認動畫。我只是想直接跳到下一個屏幕。

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 

回答

1

壞消息轉換在CardStack中被編碼。有PR已提供,但它被放棄,並沒有合併。好消息CardStackjs component,所以你可以複製和修改它。使用NavigationTransitioner的示例可在UIExplorer中找到。

編輯看起來像cardStyleInterpolator房產已於3周前添加並將在React Native 0.41中發佈。所以你可以複製新版本的NavigationCardStack.js文件給你項目並使用它。

相關問題