Code Monkey home page Code Monkey logo

react-stack-cards's Introduction

React-Stack-Cards

Collection of stack card effects exclusively for React that's perfect for galleries and preview grids. Inspired by ideas from tympanus.net. See the demo https://yoloten.github.io/react-stack-cards/

Feautures:

  • Animations on hover, swipe and toggle
  • Swipe animations allow you to work with big amount of images and colors
  • Flexible settings like adding elements into the cards, change duration of animation and etc.
  • Effects actually look awesome ๐Ÿ˜Š
  • Supports Typescript

Available components:

  • ToggleCard
  • TinderLikeCard
  • StackCard

Installation

You can install react-stack-cards from npm

npm i -S react-stack-cards

Or use yarn

yarn add react-stack-cards

Simple usage

import { ToggleCard, TinderLikeCard, StackCard } from 'react-stack-cards'

class Example extends React.Component {
  constructor(props){
    super(props)
    this.state = {
      directionTinder: "swipeCornerDownRight",
      directionToggle: "sideSlide",
      directionStack: "topRight",
      isOpen: false
    }
    this.Tinder = null
  }
  
  onTinderSwipe() {
    this.Tinder.swipe()
  }
  onToggle() {
    this.setState({isOpen: !this.state.isOpen})
  }

  render() {
    const arr = ["first", "second", "third", "fourth"]
    const numbers = [0, 1, 2, 3]
    return (
      <div>
        <ToggleCard 
          images={arr}
          width="350"
          height="240"
          direction={this.state.directionToggle}
          duration={400}
          className="toggle"
          isOpen={this.state.isOpen}
          onClick={()=> alert("Hello")}
        >
        { numbers.map( i => <div>{i}</div> )}
        </ToggleCard>
        <button onClick={this.onToggle.bind(this)}>Toggle</button>

        <TinderLikeCard
            images={arr}
            width="350"
            height="250"
            direction={this.state.directionTinder}
            duration={400}
            ref={(node) => this.Tinder = node}
            className="tinder"
        >
            { numbers.map( i => <div>{i}</div> )}
        </TinderLikeCard>
        <button onClick={this.onTinderSwipe.bind(this)}>Swipe</button>

        <StackCard
          images={arr}
          color={"#f95c5c"}
          width="350"
          height="240"
          direction={this.state.directionStack}
          onClick={()=> alert("Hello")}
        >
          <div>i</div>
        </StackCard>
      </div>
    );
  }
}

Props

Common props for all three components:

  • children - allows to add children elements (React.Element)
  • className - apply a className to the control (string)
  • direction - select animation type (string)
  • duration - set duration of animation (number)
  • images - array of images to set on the background (array of strings)
  • height - height of the card (string)
  • width - width of the card (string)

children prop can be an array of the elements or single element in TinderLikeCard and ToggleCard. StackCard only supports one element.

Special props for TinderLikeCard:

  • colors - array of colors to set on the background (array of strings)

Special props for ToggleCard:

  • colors - array of colors to set on the background (array of strings)
  • onMouseEnter - occurs when the mouse pointer is moved onto an element
  • onMouseLeave - occurs when the mouse pointer is moved out of an element
  • onClick - occurs when the user clicks on an element
  • isOpen - allows you to animate component (boolean)

Special props for StackCard:

  • color - color to set on the background (string)
  • onMouseEnter - occurs when the mouse pointer is moved onto an element
  • onMouseLeave - occurs when the mouse pointer is moved out of an element
  • onClick - occurs when the user clicks on an element

Methods

  • swipe() - swipe method for TinderLikeCard

License

MIT Licensed. Copyright (c) 2019 yoloten

react-stack-cards's People

Contributors

yoloten 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

Watchers

 avatar

react-stack-cards's Issues

tyle-value-types.es.js

hello
whene hovering i get this error in the console and the Dom get slow down:
Uncaught (in promise) TypeError: Cannot read property 'red' of null
at isRgba (style-value-types.es.js:94)
at Object.test (style-value-types.es.js:215)
at getActionCreator (popmotion.es.js:686)
at Object.vectorAction [as spring] (popmotion.es.js:673)
at getAction (popmotion-pose.es.js:320)
at convertTransitionDefinition (popmotion-pose.es.js:412)
at resolveTransition (pose-core.es.js:88)
at resolveTransition (pose-core.es.js:75)
at pose-core.es.js:191
at new Promise ()
at pose-core.es.js:176
at Array.map ()
at getParentAnimations (pose-core.es.js:169)
at Object.set (pose-core.es.js:218)
at Object.update (popmotion-pose.es.js:487)
at Observer.updateObserver (popmotion.es.js:94)
at HTMLDivElement.Observer.update (popmotion.es.js:77)

Location : style-value-types.es.js:94

but evry thing work good

Adding Link component does not work

Hi,

I modified the following StackCard code to include the call to "Link" component form react-router-dom so that user can navigate to another URL when he clicks on the card. But, adding the component code did not have any effect.

import React from "react"; import { Link } from "react-router-dom";

const solararray = [earthwebp, solarsystemwebp, moonwebp, earthwebp]

<StackCard images={solararray} width="350" height="240" direction="accordeonLeft" component={Link} to="/solarsystem" ></StackCard>

Could you please tell me what the issue could be?

Can't resolve

after compiling i get an error :
Module not found: Can't resolve 'react-card-effects'

cant install- loads of node errors

I get a crazy list of node errors when I try and install this. I'm using:

npm 6.11.3
node v11.13.0

I have a friend who has the exact same versions and he isn't getting any errors (we're also using the same package.json), so it isn't caused by the wrong version. Here is a sample of the errors, I will not copy it all:

Andrews-MBP:RealityCardsFrontEnd mcplums$ npm install

> [email protected] install /Users/mcplums/Repos/RealityCardsFrontEnd/node_modules/bufferutil
> node-gyp rebuild

  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
In file included from ../src/bufferutil.cc:16:
In file included from ../node_modules/nan/nan.h:82:
../node_modules/nan/nan_new.h:29:56: warning: 'ToInteger' is deprecated: Use maybe version [-Wdeprecated-declarations]
To<v8::Integer>(v8::Handle<v8::Integer> i) { return i->ToInteger(); }
                                                       ^
/Users/mcplums/Library/Caches/node-gyp/11.13.0/include/node/v8.h:2550:10: note: 'ToInteger' has been explicitly marked deprecated here
  inline V8_DEPRECATED("Use maybe version",
         ^
/Users/mcplums/Library/Caches/node-gyp/11.13.0/include/node/v8config.h:326:29: note: expanded from macro 'V8_DEPRECATED'
  declarator __attribute__((deprecated(message)))
                            ^
In file included from ../src/bufferutil.cc:16:
In file included from ../node_modules/nan/nan.h:82:
../node_modules/nan/nan_new.h:34:56: error: no matching member function for call to 'ToInt32'
To<v8::Int32>(v8::Handle<v8::Integer> i)   { return i->ToInt32(); }
                                                    ~~~^~~~~~~
/Users/mcplums/Library/Caches/node-gyp/11.13.0/include/node/v8.h:2531:43: note: candidate function not viable: requires single argument 'context', but no arguments were provided
  V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const;
                                          ^
/Users/mcplums/Library/Caches/node-gyp/11.13.0/include/node/v8.h:2544:30: note: candidate function not viable: requires single argument 'isolate', but no arguments were provided
                Local<Int32> ToInt32(Isolate* isolate) const);
                             ^
In file included from ../src/bufferutil.cc:16:
In file included from ../node_modules/nan/nan.h:82:
../node_modules/nan/nan_new.h:39:65: error: too few arguments to function call, single argument 'context' was not specified
To<v8::Uint32>(v8::Handle<v8::Integer> i)  { return i->ToUint32(); }
                                                    ~~~~~~~~~~~ ^
/Users/mcplums/Library/Caches/node-gyp/11.13.0/include/node/v8.h:2529:3: note: 'ToUint32' declared here
  V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToUint32(
  ^
/Users/mcplums/Library/Caches/node-gyp/11.13.0/include/node/v8config.h:418:31: note: expanded from macro 'V8_WARN_UNUSED_RESULT'
#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
                              ^
In file included from ../src/bufferutil.cc:16:
In file included from ../node_modules/nan/nan.h:82:
In file included from ../node_modules/nan/nan_new.h:189:
../node_modules/nan/nan_implementation_12_inl.h:49:38: error: too few arguments to function call, expected 2, have 1

Wat do?

TinderLikeCard Infinite Loop

Hi @yoloten, thank you for this cool package.

One question on the "TinderLikeCard" component, how do you activate the infinite loop like in your demo?

build issue

the error is in building cycle
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\SAMSUNG\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:189:13)
gyp ERR! stack at maybeClose (internal/child_process.js:970:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\SAMSUNG\Desktop\pureplayer\app\client\node_modules\utf-8-validate
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

Animation effect not smooth

Hi,

I added to my react project but the animation effect is not smooth at all. I am using the same images as you have used in your demo page and did not change any other settings from the examples but still the effect is not as smooth as the one on your demo page.

I am using version 1.0.8.

I also get the following error message in the console everytime the stackcard animates

image

Is there anything that I can do to improve the animations?

Thanks,
Niraj

Card position differs and creating empty containers

I've implemented the latest version 1.0.8, I've 4 issues.

1. when I execute toggle.swipe() it is creating empty containers beyond its limits
2. The space between cards differs across different screens
3. when I execute toggle.swipe() browser throw the in promise type error.
4. Do you have any idea to convert stacked to list view?

image

image

image

solution

hello
the module will not work because theres a mistake in your documentation
you need to import from 'react-stack-cards' instead of 'react-card-effects'
and it's worked for me
thank you

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.