2016-11-03 2 views
1

스택에 하나 이상의 경로가 없다는 네비게이션 작업을하고 있습니다.navigator.replace()의 네이티브 트랜지션 애니메이션에 반응하십시오.

그래서 pop() 및 push() 대신 replace()를 사용하고 있습니다. 하지만 주목할 문제는 replace()를 사용하는 동안 pop() 및 push()에서 볼 수있는 전환 애니메이션이 없다는 것입니다.

이 문제를 해결할 방법이 있습니까? 또는 하나의 뷰가 기존 뷰를 대체하는 탐색을 구현하는 다른 방법이 있습니까 (물론 전환 애니메이션 포함)?

+0

발견 된 솔루션? – Jickson

답변

2

동일한 문제가있어서 zhaotai에서 제공 한 here 솔루션을 찾을 수있었습니다.

문제를 해결하려면 Navigator 구성 요소를 가져 오는 js 파일에서 다음 새 메서드를 정의하십시오.

Navigator.prototype.replaceWithAnimation = function (route) { 
    const activeLength = this.state.presentedIndex + 1; 
    const activeStack = this.state.routeStack.slice(0, activeLength); 
    const activeAnimationConfigStack = this.state.sceneConfigStack.slice(0, activeLength); 
    const nextStack = activeStack.concat([route]); 
    const destIndex = nextStack.length - 1; 
    const nextSceneConfig = this.props.configureScene(route, nextStack); 
    const nextAnimationConfigStack = activeAnimationConfigStack.concat([nextSceneConfig]); 

    const replacedStack = activeStack.slice(0, activeLength - 1).concat([route]); 
    this._emitWillFocus(nextStack[destIndex]); 
    this.setState({ 
    routeStack: nextStack, 
    sceneConfigStack: nextAnimationConfigStack, 
    },() => { 
    this._enableScene(destIndex); 
    this._transitionTo(destIndex, nextSceneConfig.defaultTransitionVelocity, null,() => { 
     this.immediatelyResetRouteStack(replacedStack); 
    }); 
    }); 
}; 

그렇다면, 당신은 대신 navigator.replaceWithAnimation(route)를 호출 할 수 있습니다.

관련 문제