Coder Social home page Coder Social logo

dinneo / react-genie Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kitze/react-genie

0.0 2.0 0.0 518 KB

A set of React components for animating elements as they scroll into the viewport

Home Page: https://codesandbox.io/s/react-genie-example-8xfsc

License: MIT License

TypeScript 93.59% HTML 6.41%

react-genie's Introduction

๐Ÿงžโ€โ™‚๏ธ react-genie

๐Ÿ™‹โ€โ™‚๏ธ Made by @thekitze

Other projects:

  • ๐Ÿ’ป Sizzy - A browser for developers and designers
  • ๐Ÿซ React Academy - Interactive React and GraphQL workshops
  • ๐Ÿ’Œ Twizzy - A standalone app for Twitter DM
  • ๐Ÿค– JSUI - A powerful UI toolkit for managing JavaScript apps

Used on sizzy.co

animation

CodeSandbox

https://codesandbox.io/s/react-genie-example-8xfsc

Demo

https://8xfsc.csb.app/

Dependencies

  • styled-components
  • layout-styled-components
  • react-animations
  • react-intersection-observer

Usage

yarn add react-genie

Just render the RevealGlobalStyles component anywhere, so it will add the class names for the animations:

import {RevealGlobalStyles} from 'react-genie'

const App = () => {
  return (
    <div>
      <RevealGlobalStyles />
      <div> rest of the app </div>
    </div>
  );
};

Default animation:

import {Reveal} from 'react-genie';

<Reveal>
  <h1>The default animation is fade in</h1>
</Reveal>

Props:

{
  animation?: string; // animation class name
  delay?: number; // animation delay
  mode?: RevealMode; // "clone" or "wrap"
  debugName?: string; // if you specify it, you will get console logs
  style?: CSSObject; // extra styles
  onShowDone?: () => void; // callback after show
}

Specifying animation using the animation prop:

import {Reveal, Animation} from 'react-genie';

<Reveal animation={Animation.SlideInLeft}>
  <h1>This title will slide in from the left</h1>
</Reveal>

Hint: you can also pass your own class name here if you have custom animations.

Wrap vs Clone

The default mode is wrap, so the children element will be wrapped in an additional div. If you don't want that additional div, you can use clone or RevealMode.Clone.

import {Reveal, RevealMode} from 'react-genie';

<Reveal mode={RevealMode.Clone}>
  <h1>This h1 will be cloned instead of wrapped</h1>
</Reveal>

In order for clone to work your element needs to accept className, style, and ref, as props. So, if you're trying to clone custom components, make sure they support these props.

The AnimatedTitle component

import {Reveal, AnimatedTitle} from 'react-genie';

<AnimatedTitle>
  This sentence will animate in word by word
</AnimatedTitle>

The AnimatedTitle component will split the children prop word by word (so it should be a string), and animate each word with a delay in between.

react-genie's People

Watchers

 avatar  avatar

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.