All Projects → jondot → React Flight

jondot / React Flight

Licence: mit
The best way to build animation compositions for React.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Flight

gamma
An Eclipse-based modeling framework for the component-based design and analysis of reactive systems
Stars: ✭ 21 (-99.25%)
Mutual labels:  composition
v-bucket
📦 Fast, Simple, and Lightweight State Manager for Vue 3.0 built with composition API, inspired by Vuex.
Stars: ✭ 42 (-98.5%)
Mutual labels:  composition
tailwind-cascade
Override TailwindCSS classes for component composition
Stars: ✭ 28 (-99%)
Mutual labels:  composition
oh-migrations
Data migrations through implicit function composition at the type-level
Stars: ✭ 23 (-99.18%)
Mutual labels:  composition
swift-composable-app-example
Example iOS app built with module composition in mind.
Stars: ✭ 79 (-97.18%)
Mutual labels:  composition
cpsfy
🚀 Tiny goodies for Continuation-Passing-Style functions, fully tested
Stars: ✭ 58 (-97.93%)
Mutual labels:  composition
go-errors
A super tiny package for error encapsulation in idiomatic Go
Stars: ✭ 14 (-99.5%)
Mutual labels:  composition
total-serialism
Toolbox full of Algorithmic Composition methods
Stars: ✭ 74 (-97.36%)
Mutual labels:  composition
react-compose-events
A Higher-Order Component factory to attach outside event listeners
Stars: ✭ 25 (-99.11%)
Mutual labels:  composition
permissionary
Tiny and framework-agnostic role-based permission management using composition over inheritance
Stars: ✭ 19 (-99.32%)
Mutual labels:  composition
elastic-composer
Client-side Elasticsearch query generator and executor. Filter fields, find search suggestions, and paginate query results for your indicies using a simple, reactive, and high-level API
Stars: ✭ 14 (-99.5%)
Mutual labels:  composition
restate
A redux fractal state library 🕷
Stars: ✭ 55 (-98.04%)
Mutual labels:  composition
pyroclastic
Functional dataflow through composable computations
Stars: ✭ 17 (-99.39%)
Mutual labels:  composition
rustfst
Rust re-implementation of OpenFST - library for constructing, combining, optimizing, and searching weighted finite-state transducers (FSTs). A Python binding is also available.
Stars: ✭ 104 (-96.29%)
Mutual labels:  composition
python-composition
Code for my talk at the Python Pizza micro conference. 🧀🍅🧄🥦
Stars: ✭ 24 (-99.14%)
Mutual labels:  composition
elm-collage
Create interactive vector graphics and position them relative to each other
Stars: ✭ 57 (-97.97%)
Mutual labels:  composition
vue-snippets
Visual Studio Code Syntax Highlighting For Vue3 And Vue2
Stars: ✭ 25 (-99.11%)
Mutual labels:  composition
invokable
Objects are functions! Treat any Object or Class as a Proc (like Enumerable but for Procs).
Stars: ✭ 40 (-98.57%)
Mutual labels:  composition
bow-lite
🏹 Bow Lite is a cross-platform library for Typed Functional Programming in Swift
Stars: ✭ 27 (-99.04%)
Mutual labels:  composition
coredux
Dualism to Redux. Two-way combining of redux modules
Stars: ✭ 14 (-99.5%)
Mutual labels:  composition

https://jondot.github.io/react-flight/

The best way to build animation compositions for React. Design and compose a component to start with, a component to end with, and Flight will take it from there.

Flight tries to be for React what Principle is for Sketch compositions - the fastest, most friction free way to compose and an effortless way to animate an idea, an interaction, or a short movie-like composition in a self-contained widget (a React component after all).

Check out the new video:

React Flight in Three Minutes

Quick Start (From Scratch)

Just clone and use the example, built around create-react-app:

$ git clone https://github.com/jondot/react-flight
$ cd react-flight/examples/compos
$ yarn && yarn start

Quick Start (Existing Project)

With yarn (or npm):

$ yarn add react-flight
$ curl https://raw.githubusercontent.com/jondot/react-flight/master/examples/compos/src/index.js -o src/anim.js

And now you can frame your compositions in anim.js, require and place it in any other React component.

Next:

  1. Add jQuery (or Zepto, or any jQuery drop-in) if you don't have it already in the project.
  2. Or if you use create-react-app you can add it to your public/index.html, like here, or eject and configure webpack for jQuery.

NOTE: jQuery is currently a requirement of one of react-flight's dependencies. We plan to rebuild that dependency any way, obsoleting this requirement in the process (also: PRs accepted!).

Workflow

When you're designing compositions, focus on designing frames. The first frame is marked source because that's the starting point, and interactive because you want to play with it while you go.

  <Flight interactive ref={flight => (this.flight = flight)}>
    <Flight.Frame duration={300} source interactive showFrames>

Showing Frames

While designing, you want to have showFrames on. It will unpack all of the frames in front of you, so you could edit them while watching them. With Webpack hot-reload this becomes a fantastic experience.

When done, remove showFrames.

Controlling Flight Directly

This is where the ref addition comes in:

  <Flight interactive ref={flight => (this.flight = flight)}>
    <Flight.Frame duration={300} source interactive showFrames>

Once you can grab an instance of flight you can flight.play() and flight.reset() on demand from your own components and actions.

Here's a full layout:

  <Flight interactive ref={flight => (this.flight = flight)}>
    <Flight.Frame duration={300} source interactive showFrames>

      -- your own DOM / React Components ---
      -- starting position and styles    ---

    </Flight.Frame>

    <Flight.Frame>

      -- your own DOM / React Components ---
      -- ending position and styles    ---

    </Flight.Frame>
  </Flight>

Redux

If you're using Redux, there's basic support for it. Basic in the sense that react-flight is not going to handle deep renders of a stateful app with all its gotchas, so YMMV.

You can check out this Redux example for a fully working solution.

For your app, you can enable Redux support by indicating inclusion of store before using the Flight component:

Flight.contextTypes = {
  store: PropTypes.object,
}

Flight.childContextTypes = {
  ...Flight.childContextTypes,
  store: PropTypes.object,
}

Under the Hood

If you want to hack on react-flight, here are some context to keep in mind.

react-flight does some cool stuff and some DOM-heavy stuff (perhaps less cool?). For the cool stuff, it walks the component tree, makes decisions about what should move where, and builds a clean and nice declarative data structure that represents the way compositions should behave.

Currently it will then hand over this data to a DOM-based adapter, that also uses Velocity.js, so that it would actually orchestrate the animations. This is where you're welcome to plug in your own adapter - another animation engine, React Native, and what not.

Happy hacking!

Contributing

Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).

Thanks:

To all Contributors - you make this happen, thanks!

Copyright

Copyright (c) 2017 Dotan Nahum @jondot. See LICENSE for further details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].