npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-easy-gestures-new

v2.2.8

Published

React Native Gestures. Support: Drag, Scale and Rotate a Component.

Downloads

183

Readme

React Native Easy Gestures (w/ Bug Fixes & Patch)

React Native Gestures. Support: Drag, Scale and Rotate a Component.

  • [x] TypeScript support
  • [x] Manually editable rotate and scale value
  • [x] Rotate angle threshold added (Rotation steps added)
  • [x] Now child component can detect onPress event detection
  • [x] Ready for react 17.0.0

example

Installation

RN > 0.6 👶

$ npm install --save react-native-easy-gestures-new

RN < 0.46 👴

$ npm install --save [email protected]

Usage

this project is not 100% fully patched yet, so here's some caution: you can't statically setting the values when you have rotate or scale value and remove it. make sure rotate and scale value exists if you're using these features. ('0deg' is ok.) or you can manually edit transform value in style attribute.

import Gestures from 'react-native-easy-gestures';

/* Simple example: */
<Gestures>
  <Image
    source={photo}
    style={{
      width: 200,
      height: 300,
    }}
  />
</Gestures>

/* Only drag example witn `onChange` event: */
<Gestures
  rotatable={false}
  scalable={false}
  onChange={(event, styles) => {
    console.log(styles);
  }}
>
  <Image
    source={photo}
    style={{
      width: 200,
      height: 300,
    }}
  />
</Gestures>

/**
 * Another example:
 * Drag only on x axis;
 * Scale from 0.1 to 7;
 * Do not rotate;
 * On release callback;
 */
<Gestures
  draggable={{
    y: false,
  }}
  scalable={{
    min: 0.1,
    max: 7,
  }}
  rotatable={false}
  onEnd={(event, styles) => {
    console.log(styles);
  }}
>
  <Image
    source={photo}
    style={{
      width,
      height,
    }}
  />
</Gestures>

//Add scale and rotate props that allow statically setting the values
const [currentDeg, setCurrentDeg] = useState(180);
<Gestures
  rotate={`${currentDeg}deg`}
  scale={1}
>
  <Image
    source={photo}
    style={{
      width,
      height,
    }}
  />
</Gestures>

Props

Behavior

draggable?: boolean = true | object = { x?: boolean = true, y?: boolean = true }
rotatable?: boolean = true | object = { step?: number } (threshold angle)
scalable?: boolean = true | object = { min?: number = 0.33, max?: number = 2 }
rotate?: string (rotate value, after 'deg' is required. example: '120deg')
scale?: number

Styles

style?: StyleProp<ViewStyle> (object) // which means, RN Styles.

Callbacks

onStart?(event: object, styles: object): void
onChange?(event: object, styles: object): void
onEnd?(event: object, styles: object): void
onMultyTouchStart?(event: object, styles: object): void
onMultyTouchChange?(event: object, styles: object): void
onMultyTouchEnd?(event: object, styles: object): void
onRotateStart?(event: object, styles: object): void
onRotateChange?(event: object, styles: object): void
onRotateEnd?(event: object, styles: object): void
onScaleStart?(event: object, styles: object): void
onScaleChange?(event: object, styles: object): void
onScaleEnd?(event: object, styles: object): void

How to reset styles

<Gestures
  ref={(c) => { this.gestures = c; }}
  onEnd={(event, styles) => {
    this.gestures.reset((prevStyles) => {
      console.log(prevStyles);
    });
  }}

Development

$ git clone https://github.com/ewlkkf/react-native-easy-gestures.git
$ cd react-native-easy-gestures
$ npm install

TODO

  • [x] Rotate step, ex: every 90deg
  • [ ] Guidelines and center snap