Code Monkey home page Code Monkey logo

react-shuffle's Introduction

Maintenance Status

react-shuffle

Animated shuffling of child components

Install

npm install react-shuffle

Preview

http://i.imgur.com/B1RFfvj.gif

Usage

Simply wrap child components with this component and dynamically change them to see them animate. The only real requirement is that each child has a non-index based key, for proper position identification.

Props

Prop PropType Description
duration React.PropTypes.number Duration of animation
fade React.PropTypes.bool Should children fade on enter/leave
scale React.PropTypes.bool Should children scale on enter/leave
intial React.PropTypes.bool Should scale/fade occur on first load

Example

'use strict';

var React = require('react');

var Shuffle = require('react-shuffle');

const App = React.createClass({
  render() {
    return (
      <Shuffle>
       {// Method to render children goes here}
      </Shuffle>
    )
  }
});

module.exports = App;

Shout out

react-shuffle is heavily inspired by Ryan Florences Magic Move demo https://youtu.be/z5e7kWSHWTg

Maintenance Status

Archived: This project is no longer maintained by Formidable. We are no longer responding to issues or pull requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own!

react-shuffle's People

Contributors

ai avatar boygirl avatar jeffrifwald avatar jmcriffey avatar joshgagnon avatar kenwheeler avatar lachlanjc avatar macil avatar marcelopereirascmspain avatar peterb0yd avatar ryan-roemer avatar technikyle avatar wyze 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  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

react-shuffle's Issues

Unknown props issue

I have an issue with props. My render method is something like this :

render() {
        const language = this.props.language.default.portal;
        const cars = this.props.cars;
        const favorites = this.props.favorites;
        const cartContent = this.props.cartContent;
        const addToFavorites = this.props.addToFavorites;
        const removeFromCard = this.props.removeFromCard;
        const addToCard = this.props.addToCard;
        const handleOffers = this.props.handleOffers;
        const offers = this.props.offers;
        const currentUserEmail = getUserEmail();

        return (
            <div className="cars">
                    <div>
                        <Shuffle>
                        {cars.map((car, i) => {
                            const initialReg = car.initialRegistration.slice(0,3) + car.initialRegistration.slice(6,10);
                            // str.slice(1, 4) extracts the second character through the fourth character (characters indexed 1, 2, and 3)

                            return (
                                <div key={i} className="carBox noPadding">
                                    <div className="carBoxContent">

                                        <PhotoAndFavorites car={car} language={language} changeStarIcon={this.changeStarIcon} addToFavorites={addToFavorites} userEmail={currentUserEmail} favorites={favorites}/>

                                        <div className="carNameAndDesc">
                                            <div><Link to="" style={{textDecoration: 'none'}}>{car.make}</Link></div>
                                            <div>{car.desc}</div>
                                        </div>

                                        <div className="carPrice">
                                            <div>{car.price}</div>
                                            <div>{car.btw}</div>
                                        </div>

                                        <div className="extraFeatures" style={{marginBottom: 5, backgroundColor: '#eee'}}>

                                        </div>

                                        <div className="mainFeatures">
                                            <div><img src="../images/portal/user/status/fuel-icon.png" style={{height: 12}}/> <span>{car.fuel}</span></div>
                                            <div><img src="../images/portal/user/status/road-icon.png" style={{height: 12}}/> <span>{car.mileage}</span></div>
                                            <div><img src="../images/portal/user/status/calendar-icon.png" style={{height: 12}}/> <span>{initialReg}</span></div>
                                        </div>

                                        <Buttons car={car}
                                                 language={language}
                                                 changeButton={this.changeButton}
                                                 addToCard={addToCard}
                                                 removeFromCard={removeFromCard}
                                                 cartContent={cartContent}
                                                 userEmail={currentUserEmail}
                                                 handleChange={handleOffers}
                                                 offers={offers}
                                                 opacity={this.props.opacity}
                                                 />

                                    </div>
                                </div>
                            );
                        })}
                        </Shuffle>
                    </div>
                <div className="clearfix"/>
            </div>
        );
    }

But the animation doesn't happening and I'm getting warning
bundle.js:8394 Warning: Unknown props duration, fade, initial on div tag. Remove these props from the element. For details, see https://fb.me/react-unknown-prop

context is loose and deprecated cloneWithProps

Hi, I'm using baobab and my code works nice but today I was trying include react-shuffle and I notice than I'm receiving some errors

 Uncaught TypeError: Cannot read property 'createFacet' of undefined

I checked the error in google and end

github.com/Yomguithereal/baobab-react/issues/52

"this error occur because the rendered children has not access to the same context as set by your root component."

it's not so clear to me, context is a new (and not so much documented) feature and I can't understand how sort this problem

now, I also notice than you're actually using cloneWithProps which is the way suggested there

but seems than cloneWithProps is deprecated

now you can use https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement which keep the ref

I'm not a react expert, so I can't understand so much about it.

I hope you can understand better the problem and can give me a clue about how solve it, thanks!

Demo is broken

I don't understand how one should see the demo in demo folder?

  1. Is it using ES6 import/export stuff? You are aware it's not supported in any browser, yet, right?
  2. The js file referenced in html file is not the one next to the file

Sorting callback // use optional order attribute to sort the children

First of all, thanks for creating this! I've been desperately waiting for Ryan Florence to update his MagicMove library but it just wouldn't happen. So I'm really glad you stepped in and did some refactoring while at it.

I've got a pesky issue with your lib though: The children sorting. From both your example and the sources I assume that the ordering of child elements within the Shuffle container will be made by "greater-than" comparisons using the component's key attribute.
This seems to produce issues as React appears to use the key attribute as a unique identifier for a component.

Let me elaborate. Imagine the following racing situation UI:

[driverID: 3, pos: 3] <--- 1.8 s ---> [driverID: 2, pos: 2] <--- 0.7 s ---> [driverID: 1, pos: 1]

Since the drivers don't change in this scenario their IDs are used as the component's key attribute. React-shuffle would reorder my list and mess the position order up (3 being greater than 2, 2 being greater than 1).
As a workaround I use key={1000-pos} to get the right order. (we'll revisit this later)

I want to animate this inline-block list whenever any driver overtakes another driver, resulting in a position change. Like so:

[driverID: 3, pos: 3] <--- 2.1 s ---> [driverID: **1**, pos: 2] <--- 0.1 s ---> [driverID: **2**, pos: 1]

(the divs containing drivers 1&2 information are supposed to change positions in an animated way)

However, since I'm using {1000-pos} as the key attribute, the drivers are no longer considered the unique components. Therefore, React will merely swap the affected components' contents instead of actually rearranging the components. And thus, React-Shuffle won't animate anything because it was not the driver components' order that changed but their contents.

Introducing support for an attribute to order Shuffle's children, or for replacing the proprietary sorting function, could probably solve this issue.

Requiring react 0.14.0?

I can't get this to work with Browserify since you have a peer dependency on react v0.14.0, which as far as I can tell from the React GitHub repo, isn't out yet (current release is 0.13.3). Is there any reason you're requiring a version higher than the latest stable release?

Real shame, I'd love to use this in my app!

React 0.14 release

Wait for quick release. Current version with React 0.13 produce a lot of warnings because of cloneWithProps and context.

@kenwheeler

Can't use without `require`

I have a client using a rails asset pipeline without NPM, we just want the build to produce a standalone file.

Uncaught ReferenceError: exports is not defined

Loosing context

I use Flummox, so every component has flux context.

But If I will wrap them to <Shuffle> I will get warning from React:

Warning: owner-based and parent-based contexts differ (values: `[object Object]` vs `undefined`) for key (flux) while mounting Social (see: http://fb.me/react-context-by-parent)

React-native support, babel error

Hey, I installed the library in a react-native application, however when I try to run it I get this error:

screen shot 2017-07-31 at 09 02 09

Is this because the library is not supporting react-native, or have I done something wrong?

Container size

React Shuffle logic is to have hidden block with real controls and visible block for animation with position: absolute on top of that hidden block.

But, as result, there is no comtainer size animation, when we delete item.

Example: this is my UX:
6cijeo0

When I will delete one of item, “minus” button will move immediately to the left. Because “minus button” is out of Shuffle container and Shuffle container size has no animation.

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.