Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raphamorim/react-motions
Compose React Animations using High-Order Functions or Components
https://github.com/raphamorim/react-motions
animate animation art css css3 motions react recompose
Last synced: 13 days ago
JSON representation
Compose React Animations using High-Order Functions or Components
- Host: GitHub
- URL: https://github.com/raphamorim/react-motions
- Owner: raphamorim
- Created: 2018-03-02T03:12:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-12T01:09:34.000Z (almost 6 years ago)
- Last Synced: 2024-10-23T17:19:10.423Z (21 days ago)
- Topics: animate, animation, art, css, css3, motions, react, recompose
- Language: CSS
- Homepage: http://raphamorim.io/react-motions/
- Size: 949 KB
- Stars: 87
- Watchers: 5
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-list - react-motions - Order Functions or Components | raphamorim | 90 | (CSS)
README
# React Motions
[![CircleCI](https://circleci.com/gh/raphamorim/react-motions/tree/master.svg?style=svg)](https://circleci.com/gh/raphamorim/react-motions/tree/master)
> Compose React Animations using High-Order Functions or Components
React-Motions is a mix of ideas from [Recompose](https://github.com/acdlite/recompose) and [Animate.css](https://github.com/daneden/animate.css). In fact, `react-motions` is a set of pure functions entirely based on animation purpose.
```bash
yarn add react-motions --dev
```# Usage
Using HOF
```jsx
import { withBounce, withShake, withInfinite, withSequence } from 'react-motions'const Component =
How can I look beautifulconst ComponentWithShake = withShake(Component)
const ComponentWithShakeAndBounce = withShake(withBounce(Component))
const ComponentWithInfiniteBounce = withInfinite(withBounce(Component))
const ComponentWithShakeThenBounce = withSequence(withShake(withBounce(Component)))
```HOF - Based on Compositions
You can add compose animations (even custom animations) based on functions. Here is an example:
```jsx
import { withShake, withFadeOut, withInfine } from 'react-motions'const Component = () => (
withInfinite(
withFadeOut(
withInfinite(
withShake(
Bouncing and Fading Out infinitely!!
)
)
)
)
)
```Using Components
```jsx
import { Bounce, Shake } from 'react-motions'const ComponentWithShake = () => (
How can I look beautiful
)const ComponentWithBounce = () => (
How can I look beautiful
)
```React-Motions was created to be agnostic to the renderer:
| React Renderer | Available for use | Version |
| :--- | :--- | :--- |
| [React-DOM](github.com/facebook/react) | ✔️ | `^16` |
| [React-Native](https://github.com/facebook/react-native) | ✖️ | ✖️ |
| [React-TV](https://github.com/raphamorim/react-tv) | ✔️ | `^0.3`# API
## withInfinite
Set last animation with `infinity` property.
```jsx
import { withInfinite, withBounce } from 'react-motions'const DoNotStopBouncing = withInfinite(withBounce(
Let's bounce without stop!))
```## withSequence
Execute next animation only after previous animation be finished.
```jsx
import { withSequence, withShake, withJello } from 'react-motions'const SequencialAnimations = withSequence(
withShake,
withJello,
First shake it then jello!
)
```## compose
Execute all animations in the same time.
```jsx
import { compose, withFlash, withPulse } from 'react-motions'const VividAnimation = compose(
withFlash,
withPulse,
Flash and Pulse!
)
```## Bounce
### ComponentRender a React Component with Bounce animation (`2s` duration and iterationCount `infinite`)
```jsx
import { Bounce } from 'react-motions'const ComponentBounce = (
Let's bounce here
)
```### Function
Return a React Component with Bounce animation (`1s` duration)
```jsx
import { withBounce } from 'react-motions'const ComponentWithBounce = withBounce(
Let's bounce here)
```## FadeIn
### ComponentRender a React Component with FadeIn animation (`2s` duration and iterationCount `infinite`)
```jsx
import { FadeIn } from 'react-motions'const ComponentFadeIn = (
Let's fadeIn here
)
```
### FunctionReturn a React Component with FadeIn animation (`1s` duration)
```jsx
import { withFadeIn } from 'react-motions'const ComponentWithFadeIn = withFadeIn(
Let's fadeIn here)
```## FadeOut
### ComponentRender a React Component with FadeOut animation (`2s` duration and iterationCount `infinite`)
```jsx
import { FadeOut } from 'react-motions'const ComponentFadeOut = (
Let's fadeOut here
)
```
### FunctionReturn a React Component with FadeOut animation (`1s` duration)
```jsx
import { withFadeOut } from 'react-motions'const ComponentWithFadeOut = withFadeOut(
fadeOut here)
```## Flash
### ComponentRender a React Component with Flash animation (`2s` duration and iterationCount `infinite`)
```jsx
import { Flash } from 'react-motions'const ComponentFlash = (
Let's flash here
)
```
### FunctionReturn a React Component with Flash animation (`1s` duration)
```jsx
import { withFlash } from 'react-motions'const ComponentWithFlash = withFlash(
Flash! Flash!)
```## Jello
### ComponentRender a React Component with Jello animation (`2s` duration and iterationCount `infinite`)
```jsx
import { Jello } from 'react-motions'const ComponentJello = (
Let's jello here
)
```
### FunctionReturn a React Component with Jello animation (`1s` duration)
```jsx
import { withJello } from 'react-motions'const ComponentWithJello = withJello(
Jelloooool)
```## Pulse
### ComponentRender a React Component with Pulse animation (`2s` duration and iterationCount `infinite`)
```jsx
import { Pulse } from 'react-motions'const ComponentPulse = (
Let's pulse here
)
```
### FunctionReturn a React Component with Pulse animation (`1s` duration)
```jsx
import { withPulse } from 'react-motions'const ComponentWithPulse = withPulse(
Let's pulse here)
```## RubberBand
### ComponentRender a React Component with RubberBand animation (`2s` duration and iterationCount `infinite`)
```jsx
import { RubberBand } from 'react-motions'const ComponentRubberBand = (
Let's rubberBand here
)
```
### FunctionReturn a React Component with rubberBand animation (`1s` duration)
```jsx
import { withRubberBand } from 'react-motions'const ComponentWithRubberBand = withRubberBand(
rubberBand!)
```## Shake
### ComponentRender a React Component with Shake animation (`2s` duration and iterationCount `infinite`)
```jsx
import { Shake } from 'react-motions'const ComponentShake = (
Let's shake here
)
```
### FunctionReturn a React Component with Shake animation (`1s` duration)
```jsx
import { withShake } from 'react-motions'const ComponentWithShake = withShake(
Let's shake here)
```
## Swing
### ComponentRender a React Component with Swing animation (`2s` duration and iterationCount `infinite`)
```jsx
import { Swing } from 'react-motions'const ComponentSwing = (
Let's swing here
)
```
### FunctionReturn a React Component with Swing animation (`1s` duration)
```jsx
import { withSwing } from 'react-motions'const ComponentWithSwing = withSwing(
Swing!)
```
## Tada
### ComponentRender a React Component with Tada animation (`2s` duration and iterationCount `infinite`)
```jsx
import { Tada } from 'react-motions'const ComponentTada = (
Let's tada here
)
```### Function
Return a React Component with Tada animation (`1s` duration)
```jsx
import { withTada } from 'react-motions'const ComponentWithTada = withTada(
Tadaaaan!)
```
## Wobble
### ComponentRender a React Component with Wobble animation (`2s` duration and iterationCount `infinite`)
```jsx
import { Wobble } from 'react-motions'const ComponentWobble = (
Let's wobble here
)
```
### FunctionReturn a React Component with Wobble animation (`1s` duration)
```jsx
import { withWobble } from 'react-motions'const ComponentWithWobble = withWobble(
Wobble!)
```# Roadmap
- [ ] `withSequence`
- [ ] `compose`
- [ ] Create handler props on Components for bind Animation Hooks
- [ ] Allows to configure animation property on HOC# Credits
A thanks to [Animate.css](https://github.com/daneden/animate.css) for all animations.
Created by [Raphael Amorim](https://twitter.com/raphamorims).