GithubHelp home page GithubHelp logo

ramivalta / react-fluid-container Goto Github PK

View Code? Open in Web Editor NEW

This project forked from souporserious/react-fluid-container

0.0 2.0 0.0 80 KB

Graceful dynamic/variable height animation

License: MIT License

HTML 1.52% JavaScript 93.76% CSS 4.73%

react-fluid-container's Introduction

React Fluid Container

npm version Dependency Status

Graceful dynamic/variable height animation.

Install

npm install react-fluid-container --save

<script src="https://unpkg.com/react-fluid-container/dist/react-fluid-container.js"></script>
(UMD library exposed as `ReactFluidContainer`)

Example

Codepen Demo

import FluidContainer from 'react-fluid-container'

class App extends Component {
  constructor() {
    super(props)
    this.state = {
      showPanel: false
    }
  }

  render() {
    const { showPanel } = this.state
    return (
      <div className="accordion">
        <div
          onClick={() => this.setState({ showPanel: !showPanel })}
          className="accordion-title"
        >
          Toggle accordion
        </div>
        <FluidContainer
          height={showPanel ? 'auto' : 0}
          className="accordion-panel"
        >
          <div>Auto height animation!</div>
        </FluidContainer>
      </div>
    )
  }
}

Props

tag: PropTypes.string

The wrapping element around your only child element. Defaults to div. Any other valid props like className will be passed to this element.

height: PropTypes.oneOf(['auto', PropTypes.number])

The height value you want to animate to. Defaults to auto.

rmConfig: React.PropTypes.objectOf(React.PropTypes.number)

Pass in any valid React Motion config object.

children: PropTypes.node.isRequired (only one child allowed)

Only one child is allowed and is what the measurements will be based off of. This should be considered a pretty "dumb" element that is just a wrapper to measure off of. Make sure there are no margins are "hanging" outside of your elements. You can use 1px padding to avoid this.

beforeAnimation: PropTypes.func(currentHeight, nextHeight)

Callback before animation has started. Passes in previous and next heights.

afterAnimation: PropTypes.func

Callback after animation has completed.

Running Locally

clone repo

git clone [email protected]:souporserious/react-fluid-container.git

move into folder

cd ~/react-fluid-container

install dependencies

npm install

run dev mode

npm run dev

open your browser and visit: http://localhost:8080/

react-fluid-container's People

Contributors

npmcdn-to-unpkg-bot avatar sjmulder avatar souporserious avatar

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.