Code Monkey home page Code Monkey logo

touchflip-react's Introduction

touchflip-react

A Reusable Flipping Component For ReactJS

NPM

Demo

https://ahmednooor.github.io/touchflip-react

Install

npm install --save touchflip-react

Usage

import React, { Component } from 'react'

import TouchFlip from 'touchflip-react'

class Example extends Component { render () { return (
    <TouchFlip // Usage Example
        
        isFlippable={true} 
        // ^ set false to stop flipping

        showBackSide={false} 
        // ^ false: front shown. true: back shown
        // use showBackSide to manually trigger flipping

        duration={500} 
        // ^ duration of flipping animation in milli-seconds

        perspective={700} 
        // ^ 3d perspective in pixels

        timingFunction={'linear'} 
        // ^ 'ease-in' 'ease-in-out' etc.

        flipOrientation={'horizontal'} 
        // ^ can be either 'horizontal' or 'vertical'

        defaultFlipDirection={true}
        // ^ if true, rotates left to right horizontally 
        //   and down to up vertically
        // ^ if false, rotates right to left horizontally 
        //   and up to down vertically

        onBackSideShown={() => {}} 
        // ^ callback after flipping to back side

        onFrontSideShown={() => {}} 
        // ^ callback after flipping to front side

        style={{ // you can use custom styles here
            // width, height etc.
            // do not override the position attribute
        }}

        className="touchflip-main-ctr" 
        // ^ or you can use classes instead

        front={ // markup/jsx for the front side
            <div 
            style={{background: 'royalblue', width: '100%', height: '100%'}} 
            className="your-class">
                <h1>Front Side</h1>
            </div>
        }

        back={ // markup/jsx for the back side
            <div 
            style={{background: 'springgreen', width: '100%', height: '100%'}} 
            className="your-class">
                <input data-noflip type="text" /> <br />
                <input data-noflip type="range" /> <br />
                    {/* ^ use data-noflip on each element 
                        you want to prevent flipping when 
                        swiping or tapping that element */}
                <input type="button" value="Button"/> <br />
                    {/* ^ see this one does not have data-noflip, hence 
                        the flipping occurs when you swipe or tap it */}
            </div>
        }
    />
); } }

see example/src/App.js to check the code for demo app.

Development Guide

License

MIT © ahmednooor

touchflip-react's People

Contributors

ahmednooor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mshahin364

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.