Socket
Socket
Sign inDemoInstall

react-multitouch-gestures

Package Overview
Dependencies
18
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-multitouch-gestures

this is an react gesture library that supports:


Version published
Weekly downloads
30
Maintainers
1
Created
Weekly downloads
 

Readme

Source

react-multitouch-gestures

this is an react gesture library that supports:

  • tap
  • hold
  • rotate
  • pinch
  • drag with one finger
  • drag with two fingers
  • drag with three fingers

demo

How to use

function App() {
    const component = useRef(null)


    const onDrag = (pointer: IPointer) => {
        console.log("dragging")
    }

    useGestures(component, {
    onTapGesture: (pointer) => console.log(pointer.position.at(0)) //example how to print x position of tap
    onDragGesture: onDrag,
    // onPinchGesture: onPinch,
    // onRotateGesture: onRotate,
    // onDoubleDragGesture: onDoubleDrag,
    // onTripleDragGesture: onTripleDrag,
    // onHoldGesture: onHold
  },
    8, //distanceTreshold for hold gesture, the bigger number the further you can drag while holding
    1000 // time in ms when the hold activates
  )

  return (
    <div className="App"
      ref={component}
      style={{ touchAction: 'none' }} //you need to disable default browser gestures
    >
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          react-multitouch-gestures
        </p>
      </header>
    </div>
  );
}

how to run this repository

"clone this repository"
"uncomment lines in tsconfig.json"
npm i
npm run start

Keywords

FAQs

Last updated on 14 Aug 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc