1.2.9 • Published 5 years ago

@react-page-transition/core v1.2.9

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

@react-page-transition/core

Why?

To create page transitions with any router without pain

Allows to create route-based animations (different animations for different route combinations)

Install

yarn add @react-page-transition/core

Usage

To start annimating pages you need to do 2 things (there is an example below):

Example:

1) config

We use express-like routes and classNames list from react-transition group

const routeAnimations = [
  {
    prevRoute: '/home',
    nextRoute: '/career/:id',
    styles: {
      enter: 'my-enter',
      enterActive: 'my-active-enter',
      exit: 'my-exit',
      exitActive: 'my-active-exit',
    },
  },

  // or if you're using CSS-modules you can import whole CSS file, where classes named like 'enter', 'enterActive' etc
  {
    prevRoute: '/about',
    nextRoute: '/home',
    styles: backwardsCSSfile,
  },
]

2) <PageTransition />

import { PageTransition } from '@react-page-transition/core' // the core component
import { createUseNextRouter } from '@react-page-transition/use-nextjs' // one of the hooks for different routers
...
  <PageTransition
    useRouter={createUseNextRouter()}
    timeout={{ enter: 900, exit: 900 }}
    routeAnimations={routeAnimations}
  >
    <Component {...pageProps} />
  </PageTransition>

Other examples

Available in examples

Requirements

React 16.8 and higher

Router plugins

To use page transitions with every router you need a suitable plugin

@react-page-transition/use-nextjs is currently available for nextjs users

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago