Giter Club home page Giter Club logo

element-motion's Introduction

Element Motion

This has been archived. If you're looking for a solid implementation of an animation engine/FLIP style animations that are easy to use I highly recommend checking out Framer Motion.

The latest update with the animate prop truly is the nail in the coffin for Element Motion - it does everything this library does and more with a fantastic API.

Check it out here: https://www.framer.com/motion/


Tween between view states with declarative zero configuration element motions for React.

npm npm bundle size (minified + gzip)

Moving from a persisted element Moving to another distinct element Moving using a focal target

Dynamic motions as easy as:

<Motion triggerSelfKey={isLarge}>
  <Scale>{motion => <div {...motion} className={isLarge ? 'large' : 'small'} />}</Scale>
</Motion>

Get started

Check out our example motions and then once you're done have a look at the docs.

Installation

Element Motion requires React 16.4 or greater.

npm install @element-motion/core --save

or

yarn add @element-motion/core

Whats in a motion?

There are two halves to Element Motion:

  • Orchestration (collecting DOM data, enabling motion between disconnected React elements, executing motions)
  • Motions (animation concerns, CSS transitions/animations, JS animations, whatever you can imagine)

Next steps

Talks

Element Motion @ React Sydney 3rd June 2019 Slides
React Sydney - 3rd June 2019

element-motion's People

Contributors

itsdouges avatar jesstelford avatar madou avatar styfle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

element-motion's Issues

Motion roadmap

Two goals for this:

  1. Introduce new animations and make a suite of good looking examples, taking inspiration from https://material.io/design/motion
  2. Make internal changes if needed for more advanced animations

Move

Focal reveal move

Arc move

Fixed focal cross fade

Loose focal cross fade

Fixed cross fade

Material expanding

Reshaping container

Notes

Material motion repo is gold for some animations https://github.com/material-motion/material-motion-swift !

Figure out best way to handle any type of transition child

Depending on the CSS of the child we need to override some styles so it looks correct.

This could be as simple as providing a hook for consumers to pass in extra styles on transition, or as complicated as automatically setting style values dependent on already set styles.

Devils advocate: Maybe it's ok to force consumers to style their elements a particular way?

Setup deployment pipeline in travis

  • Setup travis yml
  • Write publish script that calls out to lerna during publish script step
  • Setup bundle to not include externals (react)
  • Get rid of unneeded files in package
  • Update changelog on npm version

TransitionContainer should be able to work on the server

Currently it uses componentWillMount hook to register its listener before anyone else. This is because it needs to be told when the show itself. We need to figure out how to add all listeners before they're notified on mount.

I tried allowing the listener to be notified post initial set, but it broke things.

react-yubaba-next

  • Add typescript support
  • Support react only
  • Rip out core library
  • Swipe animation
  • Remake examples in react-next module
  • Support drag and drop patterns (ala google image search mobile) (supported via in prop)
  • Support imperative method of triggering animations (not needed anymore)
  • Support destination node already existing when source node unmounts (implemented with prop in)
  • Work around current limitation of in prop where series of events matters to ensure we have the stored data.
  • Transition aborting
  • Cross browser support regression test (ie11, latest 1 version)
  • NPM deployment
  • Readme

Improve docs with more examples - more code

Also: #30

Obviously we don't want to handle this - but it's a good pattern to use to keep transitions nice and fluid.

E.g. Scroll down to and click an item on items page, transition to details page, close details page, initial scroll position from items page should be set again.

Rethink if animate needs a wrapper element

Potentially we could just pass props down to the children, but it would require some extra work from consumers if they nest a custom component (need to pass the props + ref down).

Caveats:

  • We pass ref down. We'd have to handle both native and custom components (ref for native, refFunc for custom, since you can't set ref to custom directly)
  • We pass style down. Consumers would be slightly inconvenienced if they too use style (need to merge them)

Rename Move to something more appropriate

Since we'll eventually be introducing other types of movement (FlipMove), would be great if we renamed Move to something more explicit.

CloneMove?
CrossFadeMove?

First step would be to rename in docs and add a new export.
Second step (breaking change) would be to remove the old export.

Refactor internal API for starting animations

Atm it's quite cumbersome to start a new animation, it requires the developer to manually create their own react instance and then mount in the DOM themselves in the animation hooks.

Wouldn't it be nice if we had some way of doing this generically, instead of each animation doing it themselves?

Mention storing scroll position for going "back" in docs

Obviously we don't want to handle this - but it's a good pattern to use to keep transitions nice and fluid.

E.g. Scroll down to and click an item on items page, transition to details page, close details page, initial scroll position from items page should be set again.

Modify move/expand transitions to support fixed position

Fixed position will be important if we want to be able to transition between routes and support immediately scroll to top on the incoming page.

This will enable nice transitions at the cost of having to disable the user from scrolling, else the illusion will be broken.

Blanket performance improvements

Two things come to mind:

  1. "Prewarm" the animations by deferring the "start" for 1~n frames (see: android examples of doing just this)
  2. Use css will-change

Create FLIPMove component

This would be trading off versatility for performance (probably).

See:
https://github.com/joshwcomeau/react-flip-move
https://github.com/aholachek/react-flip-toolkit

For some inspiration.

Quick refresher of how it would work:

  • Get position difference of start/end elements
  • Apply difference to end element via transform immediately
  • Next animation frame remove the transform, watch it animate into place

๐Ÿ‘Œ ๐Ÿ‘Œ ๐Ÿ‘Œ

This will be about as performant as we can make it, but will make other things slightly harder (hiding content around element, cross fade elements, etc).

Add ability to have an animation when Animate component is mounted

Problems

  • If a component changes size on mount and we are transitioning to it, we currently transition to the initial state of the animation, not the end. So for example we might transition to a smaller version of the target. I think we can solve this by using offsetHeight and offsetWidth instead of element.getBoundingClientRect() when calculating the to element.
  • When a yubaba animation is happening, we'd want to delay the on mount animations for a little bit. Maybe.

Support changing target element of inflight animations

Essentially this is to support "cancelling" animations.

However - this isn't a true cancel. It's basically creating a new animation with the from element being the inflight element, and the to element being the freshly mounted target.

FLIP the transitions

Atm transitions are starting at the start point then applying the transforms.

To get some gainz we can flip it, and start at the destination, apply transforms to get back to the start point, and then remove the transforms to start the transition. This will result in more performance animations.

However, we are using the web animations api. Can FLIP even work in this scenario?

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.