react-router-transition icon indicating copy to clipboard operation
react-router-transition copied to clipboard

Transition to the next page directly

Open nukeop opened this issue 7 years ago • 5 comments

I'm using this code to great effect, thank you for sharing it. I have a following question: right now using a transition makes the program correctly leave the previous view, but it transitions to an empty page, then the next view pops in. Is there a way to make it transition directly to the next page?

nukeop avatar Jul 27 '17 14:07 nukeop

@nukeop thanks for the kind words.

it depends on how you're composing it. are you wrapping individual routes with the RouteTransition component or are you wrapping a set of routes?

maisano avatar Jul 27 '17 15:07 maisano

I'm wrapping a Switch component in the RouteTransition. I want to apply the effect only to a particular block on the page. Here's the relevant render function:

  render() {
    return(
      <Route render={({location, history, match}) => {
        return (
          <MainLayout>
            <RouteTransition
              pathname={location.pathname}
              atEnter={{ opacity: 0 }}
              atLeave={{ opacity: 0 }}
              atActive={{ opacity: 1 }}
              className={styles.transition}
            >
              <Switch key={location.key} location={location}>
                <Route path="/album/:albumId" component={AlbumViewContainer} />
                <Route path="/artist/:artistId" component={ArtistViewContainer} />
                <Route path="/dashboard" component={Dashboard} />
                <Route path="/" component={SearchResultsContainer} />
              </Switch>
            </RouteTransition>
          </MainLayout>
        );
      }
    }>

    </Route>
  );
}

nukeop avatar Jul 27 '17 15:07 nukeop

@nukeop what happens if you set the RouteTransition's pathname prop to be location.key?

also, what styles are being set via the styles.transition class name?

maisano avatar Jul 31 '17 14:07 maisano

changing pathname to location.key didn't help.

The scss sheet sets the following properties:

.transition {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: 1rem;
}

nukeop avatar Jul 31 '17 15:07 nukeop

Also experiencing this exact issue with AnimatedSwitch. @nukeop did you figure out how to fix this?

ColinVDH avatar Oct 04 '17 14:10 ColinVDH