Giter Site home page Giter Site logo

react-hold-button's Introduction

react-hold-button

A button you have to press for some time before it fires

example

Usage

1. install the lib

$ npm install react-hold-button

2. import the component

import HoldButton from 'react-hold-button';  

3. use the component

A complete example is available in ./example folder.

<HoldButton onLongPress={exampleCallback} Content="text" />

or try it out instead

git clone
npm install
npm run dev

Properties:

  • onLongPress - [function] button callback
  • Content - [string|object] button content

Style

react-hold-button is based on the transitionend event, some CSS is required. heres an example. you can build your own using the .done and .holding css classes

    .hold-btn-container{
        background: #CCC;
        width: 100px;
        height: 100px;
        padding:2px;
        border-radius: 50%;
    }

    
    .hold-btn{
        width: 33%;
        height: 33%;
        position: relative;
        top:33%;
        left:33%;
        background: red;
        border-radius: 50%;
        transform:scale(1); 
        transition:transform 0.25s ease-out;
        cursor:pointer;
        text-align: center; 
        user-select: none; 
        -webkit-user-select: none; 
        -ms-user-select: none; 
    }

    .hold-btn span{
        display: inline-block;
        width: 100%;
        margin-top: 22%;
        user-select: none; 
        -webkit-user-select: none; 
        -ms-user-select: none; 
    }

    .hold-btn.holding{ 
        transform:scale(3); 
        transition:transform 1.75s  ease-in;
    }

    .hold-btn.done{
        opacity: 0;
        transform:scale(6); 
        transition:all 0.35s ease-in;
        cursor: default;
    }

react-hold-button's People

Contributors

entomb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.