2.0.3 • Published 5 years ago

react-slide-animation-router v2.0.3

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

React Slide Animation Router

avatar

react router左右滑动动画的封装。

The react router slides around the animation.

Usage

$ npm install react-slide-animation-router
import { Route, Router } from 'react-router-dom'
import SlideRouter, { initSlideRouter } from 'react-slide-animation-router'
import { createBrowserHistory } from 'history'
const history = createBrowserHistory()

// 必须在创建路由之前调用initSlideRouter
// The initSlideRouter must be called before the route is created
initSlideRouter({
  history,
  routeAnimationDuration: 350
})

const renderRouter = () => {
  return (
    <SlideRouter>
      <Route path={'/'} component={Page1} exact={true}/>
      <Route path={'/p2'} component={Page2} exact={true}/>
      <Route path={'/p3'} component={Page3} exact={true}/>
    </SlideRouter>
  )
}

Api

initSlideRouter options

keydetailtypedefault
routeAnimationDurationThe duration of the route animationnumber350
historyhistory objectobject-
wrapIdrouter container idstringslide-router-wrap
classNamesrouter animation class namestringslide-router
isRememberPositionwhether to remember the scroll positionbooltrue
transitionPropsreact-transition-group parametersobject-

disable animation:

Pass in noAnimate in state

history.push('/your-path', { noAnimate: true })
history.pop('/your-path', { noAnimate: true })
history.replace('/your-path', { noAnimate: true })