Giter Site home page Giter Site logo

simonselg / react-overdrive Goto Github PK

View Code? Open in Web Editor NEW

This project forked from berzniz/react-overdrive

0.0 3.0 0.0 5 MB

Super easy magic-move transitions for React apps

Home Page: https://react-overdrive.now.sh

License: MIT License

JavaScript 100.00%

react-overdrive's Introduction

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.
tag A unique string which servers as a sub-id.
acceptFrom A array of tags. Only these tags can transition to this 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.

react-overdrive's People

Contributors

abstracthat avatar berzniz avatar diegomura avatar knpwrs avatar lex111 avatar na-ji avatar pizza3 avatar sbking avatar simonselg avatar timbuckley avatar vasco-santos avatar yujiangshui avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.