• Stars
    star
    141
  • Rank 259,347 (Top 6 %)
  • Language
    JavaScript
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React Animated Styled Components

Animated Styled Components

React Animated Styled Components is a library that aims to make ease to use plug and play animated components.

Installing Animated Styled Components

NPM

npm i --save animated-styled-components

YARN

yarn add animated-styled-components

Demo

You can check for a working CodeSandbox to see a small demonstration of this library.

Using the Animated Component

To make use of the Animated component you need to include the library into your project and create a new component just like you would do with any other react component.

import React, { Component } from 'react';
// Make the import into your react component file
import { Animated, FadeAnimations, RotateAnimations } from 'animated-styled-components';

class Showcase extends Component {
  render() {
    return (
      <div>
        <Animated
          animation={{
            delay_in: 5,
            in: FadeAnimations.FadeInBottom,
            duration_in: 1,
            continuous: RotateAnimations.RotateCenter,
            duration_continuous: 1,
            out: FadeAnimations.FadeOutTop,
            duration_out: 1,
            delay_between: 5
          }}
          transitions={[
            {
              type: 'hover',
              from: { property: 'border-radius', value: 0 },
              to: { property: 'border-radius', value: 10 }
            }
          ]}
        >
          This is an animated component
        </Animated>
      </div>
    );
  }
}

At the above example you can see a basic structure of an Animated Component. We will dig more into all the props later on this documentation.

Props

The Animated Component doesn't need to be filled with any props, if you don't provide props, it will just simply do nothing, but, to make the magic happen, those props are the following: animation and transitions.

Animation Prop

The animation prop is an object that needs to have the following structure:

animation={{
  delay_in: 5,
  in: FadeAnimations.FadeInBottom,
  duration_in: 1,
  continuous: RotateAnimations.RotateCenter,
  duration_continuous: 1,
  out: FadeAnimations.FadeOutTop,
  duration_out: 1,
  delay_between: 5,
  iteration: 
}}

Deconstructing the animation prop

  • in: This property receives an animation keyframe that will be used to animate in the component.
  • delay_in: This property receives and integer and will set the time that the component will take to start being animated. While this time isn't reached, the component will be mounted but will display nothing. If this property is not setted there won't be any delay in for the component to start animating.
  • duration_in: This property receives and integer greater than 0 and will set the duration in seconds for the in animation.
  • continuous: This property receives an animation keyframe that will be used to animate between in and out (if proceed).
  • duration_continuous: This property receives an integer greater than 0 and will set the duration in seconds for the continuous animation.
  • out: This property receives an animation keyframe that will be used to animate out the component.
  • duration_out: This property receives and integer greater than 0 and will set the duration in seconds for the out animation.
  • delay_between: This property receives and integer geater or equals to 0 and will set the time that will wait between the in and out animations.
  • iteration: This property receives and integer greater than 0 or the literal 'infinite' and will set the amount of iterations the animation should be doing until it goes out (if it should).

Transitions Prop

The transitions prop is an array of objects with the desired transitions that should be handled and needs to have the following structure:

transitions={[
  {
    type: 'hover',
    from: { property: 'border-radius', value: 0 },
    to: { property: 'border-radius', value: 10 }
  }
]}

Deconstructing the transitions prop

An array of objects that must contain the following structure:

  • type: This property must be a string literal from the following literals available: hover, focus, blur, active. This property is the one who's going to set the type of transition we want to achieve.
  • from: This property will define the starting values of the properties to transition. This property must be an object with the following inner properties:
    • property: This property must be a valid CSS property (it will be checked to avoid using unknown properties).
    • value: This property must be a string or a number depending on the property type (will be automatically checked to prevent inconsistencies).
  • to: This property will define the ending values of the properties to transition. This property must be an object with the following inner properties:
    • property: This property must be a valid CSS property (it will be checked to avoid using unknown properties).
    • value: This property must be a string or a number depending on the property type (will be automatically checked to prevent inconsistencies).

Animations

This component gives you a lot of built-in animations that are well tested and ready to be used.

If you want to use our built-in animations you only need to to the following when importing animated-styled-components:

{ AnimationsType } from 'animated-styled-components';

Where AnimationsType are one of the following avaible grouped animations. Each of this groups have the animations.

BounceAnimations

With the following implemented animations:

BounceInForwards


ScaleAnimations

With the following implemented animations:

ScaleInCenter


FadeAnimations

With the following implemented animations:

FadeIn

FadeInTop

FadeOutTop

FadeInBottom

FadeInLeft

FadeInRight


RotateAnimations

With the following implemented animations:

RotateInCenter

RotateCenter


SlideAnimations

With the following implemented animations:

SlideTop

More Repositories

1

react-mobx-state-tree

Create React App with MobX State Tree, Styled Components and GraphQL
JavaScript
133
star
2

react-mobx-router

Create React App with React Router 4 and MobX + Internationalization
JavaScript
89
star
3

react-onboarding

Onboarding library for React
TypeScript
34
star
4

react-mobx-router-electron

React Create App with React Router and MobX and Internationalization and Electron
JavaScript
22
star
5

react-spring-pop

Animate React elements when they enter the viewport with physics based animations
TypeScript
18
star
6

react-forum-system

React Forum System
JavaScript
16
star
7

cratebox

A global, fast content delivery network for NPM
TypeScript
15
star
8

react-native-loading-dots

A React Native loading component with dots or custom components and a smooth animation
13
star
9

reactron

Build Desktop Applications with React and Electron
JavaScript
6
star
10

cratebox-react

React bindings for Cratebox
TypeScript
4
star
11

graphdb

An in memory database with sync capabilities
TypeScript
3
star
12

use-observer

React Intersection Observer implementation done right!
TypeScript
2
star
13

screen-corsair

Navigation for React Native
JavaScript
2
star
14

fib-o

A cached fibonacci implementation
JavaScript
2
star
15

react-spotify

Spotify Web Client built with React
JavaScript
1
star
16

learning-rust

A repository containing all my Rust language training
Rust
1
star
17

onboarding-demo

This repo contains a demo for @reactive-labs/onboarding library
JavaScript
1
star
18

gatsby-sass-modules

This repository is to showcase the bug that happens in Gatsby when trying to use sass with CSS Modules
CSS
1
star
19

react-native-undetermined-progress

Undetermined Progress Bar component for your React Native application
1
star
20

erat-o

Eratosthenes primality test implementation
JavaScript
1
star
21

alexvcasillas

✨special ✨
1
star
22

alexvcasillas.com

Alex Casillas' Personal Website
JavaScript
1
star
23

grapher

User Interface Library
1
star
24

fact-o

A factorial implementation
JavaScript
1
star
25

Google-Fonts-JSON-to-Google-Font-Format

Convert a Google Fonts list on format JSON to a Google Fonts official valid format.
JavaScript
1
star
26

cratebox.io-docs

Cratebox.io documentation website
JavaScript
1
star
27

workchitecture

Worker based architectured that separates UI, state and other operations with Web Workers
JavaScript
1
star