Giter Club home page Giter Club logo

react-magician's Introduction

React Magician

Declaratively animate React components. React Magician aims to be simple to use, yet flexible and powerful.

Example:

this.animations = {
      fooBarAnimation: Animation.create({
        '0ms': { // time based
          blockA: {
            left: 0,
            position: 'absolute',
            top: 0,
            width: 200,
            transform: 'rotate(0deg)'
          },
          blockB: { // yes, we support multiple elements
            left: 0
          }
        },
        'a: ?ms': { // we don't know how long this lasts, the spring easing determines when it ends.
                    // a: indicates a label with the name a
          blockA: {
            left: 100,
            transform: 'rotate(90deg)', // we automatically make this work for you
            easing: EasingTypes.spring({
              mass: 1,
              spring: 30,
              damping: 4
            })
          }
        },
        '400ms': { // here we animate the top based on time, with the default linear easing
          blockA: {
            top: 300
          }
        },
        'b: ?ms': {
          blockB: {
            left: 1000,
            easing: EasingTypes.spring({
              mass: 1,
              spring: 50,
              damping: 3
            })
          }
        },
        'a + 100ms': { // 100ms after animation block with label a is done
          blockA: {
            left: 20
          }
        },
        'a + 2000ms': {
          blockA: {
            left: 100
          }
        },
        'a + b + 200ms': { // 200ms after both a and b are done
          blockB: {
            left: 100
          }
        }
      })
};

Future plans

The current focus is on the API, and making it simple to orchestrate complex animations based on time, touch or mouse. For now we're mostly focusing on making sure the timing API provides everything that's needed.

Performance:

  • re-use objects

LICENSE

MIT

react-magician's People

Contributors

sanderspies avatar

Stargazers

Yasin ATEŞ avatar Florian Berg avatar Christi Reid avatar Marc-antoine Lévesque avatar Chris Watson avatar Eric Lei He avatar Ronaldo Lima avatar Rick Rickards avatar Martin Vanni avatar Ernst Salzmann avatar Muhammad Adeel avatar Konstantin Kalbazov avatar Brandon Smith avatar Jacob Beltran avatar Quentin Jaccarino avatar MaX Falstein avatar David Andrus avatar Michael Warkentin avatar Nick Presta avatar Hasnat avatar Scott Jason avatar Austin Mao avatar Harald avatar Ignacio Gutierrez avatar Prabhanjana Kumar C avatar Robert Haritonov avatar Sebastian Sandqvist avatar Angus H. avatar Mark Miro avatar  avatar Sonny avatar Shane Wilson avatar Johnny Hauser avatar Chris Morrell avatar Will Washburn avatar Brian Hinton avatar Martin Eigenmann avatar Charlie Liang Yuan avatar Georges Baladi avatar Mohammad Sadegh Khoeini avatar Ling Zhang avatar floydwch avatar Chris avatar Gabriel Almeida avatar Luke Barbuto avatar Esdras Mayrink avatar haoran avatar Alexandr avatar Dmitry Chestnykh avatar Jason Beatty avatar Warren Mira avatar Marcus Vorwaller avatar Jesse avatar Darek Rossman avatar weijarz avatar Ben avatar Joseph Kim avatar Michael Hanson avatar Rafau avatar 唐睿 avatar B avatar  avatar Guten avatar  avatar Berk Birand avatar Vasiliy Yorkin avatar Willem Labuschagne avatar Martin Daniel Kolpak avatar Pedro Henriques dos Santos Teixeira avatar Vladimir Kapustin avatar Danny Richelieu avatar spencer kelly avatar Joe Webb avatar Siddhartha Basu avatar Gustaf Dalemar avatar Sri Kadimisetty avatar Sebastian Buys avatar Lari Hoppula avatar Michael Chan avatar Kav Singh avatar Thomas Reggi avatar Alessandro Arnodo avatar Steve Farthing avatar Tarrence van As avatar Ben McMahen avatar Pierre Arnaud avatar Petri Kola avatar Alex Kirszenberg avatar  avatar Seb Insua avatar  avatar Seggy Umboh avatar Zdeněk Topič avatar Tomas Ruzicka avatar Pavel Moravec avatar Isaac Huang avatar Jan Killian avatar Max Greb avatar Jake Trent avatar Riley Shaw avatar

Watchers

Nathan Hutchision avatar James Cloos avatar  avatar Michael Anthony avatar Karl P avatar

react-magician's Issues

Support complex values

Like:

0, 0, 0, 0
0 0 0 0
translate(1, 2)
skewX(2, 3)
etc.

Should be solved at initialization.

Implement Animation.render function

For 60fps animations it's wiser to skip React's rendering pipeline, and directly modify the style attribute of elements.

How should it work

render() {
   return Animation.render(this, () => {
      // standard React stuff
   });
}

Animation.render calls the given function when:

  • first time
  • props / state changed

Animation.render won't call the function and directly modify the DOM element style prop when:

  • second time
  • props / state not changed

Need to solve:

  • how to connect animating elements with React Magician?

Add Spring easing

Borrow from here for now: https://github.com/iamralpht/iamralpht.github.io/tree/master/physics

Use npm package when available.

Syntax-wise it should be something like:

      fooBarAnimation: Animation.create({
        '0ms': {
          blockA: {
            left: 0,
            top: 0,
            width: 0,
            transform: 'rotate(0deg)'
          },
          blockB: {
            left: 0,
            top: 0
          }
        },
        '100ms': {
          blockA: {
            easing: Spring({
              spring: 2,
              damping: 2
            }),
            left: 100
          }
        }
  });

Also investigate other options, like gravity support.

Support visibilitychange

The animation currently does play correctly if you switch tabs due to using Date.now(). A solution for this would be to use the visibilitychange event.

Should work like this:

  • pause on hidden
  • play on visible

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.