• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

berzniz/react-overdrive: Super easy magic-move transitions for React apps

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

berzniz/react-overdrive

开源软件地址:

https://github.com/berzniz/react-overdrive

开源编程语言:

JavaScript 100.0%

开源软件介绍:

react-overdrive

Super easy magic-move transitions for React apps.

Demos

  1. Page transitions

Overdrive Demo

  1. Image Gallery with next.js

Overdrive Demo

  1. With React Router

Overdrive Demo

Install

$ npm install react-overdrive --save

Usage

Example with routing

Wrap any element (not just images) in a <Overdrive id=""></Overdrive> component. Add the same id to create a transition between the elements.

On page1.js:

import Overdrive from 'react-overdrive'

const pageA = (props) => (
  <div>
    <h1>Page A</h1>
    <Overdrive id="bender-to-big-fry">
      <img src="bender.png" width="100" height="100"/>
    </Overdrive>
  </div>
);

On page2.js:

import Overdrive from 'react-overdrive'

const pageB = (props) => (
  <div>
    <h1>Page B</h1>
    <Overdrive id="bender-to-big-fry">
      <img src="fry.png" width="300" height="300"/>
    </Overdrive>
  </div>
);

Now route between the pages.

Example without routing

On page.js:

import Overdrive from 'react-overdrive'

const page = (props) => (
  <div>
    {props.loading && <Overdrive id="content"><Loader/></Overdrive>}
    {!props.loading && <Overdrive id="content"><Content/></Overdrive>}
  </div>
);

API

Prop Description Default Value
id Required. A unique string to identify the component.
element Wrapping element type. 'div'
duration Animation duration (in milliseconds). 200
easing Animation easing function. ''
animationDelay Add delay of calculating the mounted component position. Setting to 1 usually helps avoiding issues with window scrolling. null
onAnimationEnd Event dispatched when the animation has finished. null

How does it work?

A transition is made when an <Overdrive id="example"/> component is unmounted and another <Overdrive id="example"/> is mounted not later than 100ms.

The transition is made by cloning the unmounted and mounted components, adding them with absolute position and CSS transformed from the source to the target position.

Sponsors

Thanks to the following companies for generously providing their services/products to help improve this project:

Thanks to BrowserStack for providing cross-browser testing.

Who made this?

Tal Bereznitskey. Find me on Twitter as @ketacode.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap