Skip to content
  • Sebastian Markbåge's avatar
    Rerender useSwipeTransition when direction changes (#32379) · 88479c6f
    Sebastian Markbåge authored
    We can only render one direction at a time with View Transitions. When
    the direction changes we need to do another render in the new direction
    (returning previous or next).
    
    To determine direction we store the position we started at and anything
    moving to a lower value (left/up) is "previous" direction (`false`) and
    anything else is "next" (`true`) direction.
    
    For the very first render we won't know which direction you're going
    since you're still on the initial position. It's useful to start the
    render to allow the view transition to take control before anything
    shifts around so we start from the original position. This is not
    guaranteed though if the render suspends.
    
    For now we start the first render by guessing the direction such as if
    we know that prev/next are the same as current. With the upcoming auto
    start mode we can guess more accurately there before we start. We can
    also add explicit APIs to `startGesture` but ideally it wouldn't matter.
    Ideally we could just start after the first change in direction from the
    starting point.
    88479c6f