Skip to content

NavigationExperimental is broken when native animations are used #11377

@bendman

Description

@bendman

Description

NavigationExperimental always renders the last card in a stack after completing the first transition, even if the last card wasn't the target. It only (and always) occurs if enableGestures={false}, which is required if you want to take advantage of native animations.

Expected:

  1. Render a CardStack with two cards, 0 and 1, starting on 1
  2. Trigger a transition to card 0
  3. Card 0 is animated into frame
  4. After animation, card 0 is shown

Actual:

  1. Render a CardStack with two cards, 0 and 1, starting on 1
  2. Trigger a transition to card 0
  3. Card 0 is animated into frame
  4. After animation, card 1 is shown

nav-animation

Reproduction

RNPlay uses an old version of React Native, so it can't be used to reproduce this bug. The bug is visible by running the reduced case in this repository: https://github.com/bendman/rn-navigator-bug

Solution

A temporary fix for library consumers is to remove enableGestures="false", thereby not taking advantage of native animation optimizations that were made available in this commit. This also prevents consumers from disabling gestures.

That solution isn't great because it forces a fallback to JS animation, which is slower. A more permanent solution would be to fix the native animation to render the correct card after a transition.

A middle-ground solution would be to add a separate flag for enableNativeAnimation={bool}, allowing consumers to set:

enableNativeAnimation={false}
enableGestures={false}

This would make it possible to disable gestures while still having a working navigator.

Additional Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions