• Stars
    star
    181
  • Rank 212,110 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A react native component to help with common use cases for scrolling/panning/etc

react-native-pan-controller

Motivation

The PanResponder class in React Native is incredibly useful, and can handle a broad range of interactions/animatinos. Unfortunately, there are a lot of very common interactions/animations that require a lot of the same boilerplate in order to get them working properly, and that code is not necessarily straight forward.

The <PanController /> component is intended to much more easily handle a lot of these common scenarios. See below for usage.

Installation

$ npm install --save react-native-pan-controller

API (props)

Behavior Config

Prop Default Type Description
panX new Animated.Value(0) Animated ...
panY new Animated.Value(0) Animated ...
horizontal false Boolean ...
vertical false Boolean ...
lockDirection true Boolean ...
overshootX "spring" `"spring" "clamp"`
overshootY "spring" `"spring" "clamp"`
xMode "decay" `"decay" "snap"
yMode "decay" `"decay" "snap"
xBounds [-Infinity, Infinity] Array<Number> ...
yBounds [-Infinity, Infinity] Array<Number> ...
snapSpacingX null Number ...
snapSpacingY null Number ...

Animation Config

Prop Default Type Description
overshootSpringConfig { friction: 7, tension: 40 } Object ...
momentumDecayConfig { deceleration: 0.993 } Object ...
springOriginConfig { friction: 7, tension: 40 } Object ...
directionLockDistance 10 Number ...
overshootReductionFactor 3 Number ...

Events

Prop Parameters Description
onOvershoot NO ...
onDirectionChange NO ...
onReleaseX NO ...
onReleaseY NO ...
onRelease NO ...

Examples

There is an example project where you can run and inspect all of the below examples if you want. In order to do so, you must first do the following:

$ cd examples
$ npm install

ScrollView

CoverFlow

PageScroller

PullToRefresh

Chat Heads

Window Shade

Contributing

PR's welcome. Additionally, if you have an interaction that you think might be able to be handled by the PanController, but you're not quite sure how to implement it, give me an example of the interaction and I'll try to get it working and add an example.

If it is not easily implemented using the PanController, but seems like a strong use-case, I may extend the implementation to handle it more easily.

License

MIT License.

More Repositories

1

react-primitives

Primitive React Interfaces Across Targets
JavaScript
3,085
star
2

redux-pack

Sensible promise handling and middleware for redux
JavaScript
1,333
star
3

react-native-parallax-view

Parallax view for vertical scrollview/listviews with a header image and header content
JavaScript
1,284
star
4

redux-injectable-store

Redux store with injectable reducers for use with bundle splitting, large apps, and SPAs.
JavaScript
230
star
5

react-native-segmented-view

Segmented View for React Native (with animation)
JavaScript
187
star
6

redux-entity

WIP. An abstraction layer around handling normalized entity storage and data fetching with redux
JavaScript
187
star
7

compose-dogfooding

Code written during the Compose Dogfooding streams
Kotlin
183
star
8

recoil

Swift and Kotlin ports of React (Prototype)
Swift
180
star
9

dolla

A light-weight jQuery clone just cuz
JavaScript
140
star
10

enzyme-example-mocha

Example project with React + Enzyme + Mocha
JavaScript
132
star
11

react-native-safe-module

A safe way to consume React Native NativeModules
JavaScript
118
star
12

enzyme-example-react-native

Example project with React Native + Enzyme
Objective-C
87
star
13

native-navigation-boilerplate

Objective-C
82
star
14

enzyme-example-karma-webpack

Example project with React + Enzyme + Karma + Webpack
JavaScript
82
star
15

react_native_animation_examples

JavaScript
80
star
16

react-native-in-depth

Courseware and material for a class on React Native
Objective-C
74
star
17

react-native-future

Some thoughts on future directions and APIs for React Native
67
star
18

enzyme-example-jest

Example project with React + Enzyme + Jest
JavaScript
45
star
19

BQL

BQL: A Better Query Language, SQL Superset
C#
43
star
20

react-image-magnifier

A react component that accepts a high-res source image and produces a magnifier window on mouse hover over the part of the image the cursor is over
JavaScript
39
star
21

LukeMapper

Lucene.Net Document to Object ORM Mapper inspired by Dapper
C#
36
star
22

react-validators

Enhanced React Shape PropType Validators
JavaScript
36
star
23

knockout-react

A wrapper / bridge for using React.js with Knockout and Knockout with React.js
JavaScript
25
star
24

gestio

Declarative DOM-Based Gesture Responder System
JavaScript
21
star
25

style-equal

An efficient equality algorithm for React Native inline styles
JavaScript
20
star
26

astrobin-compose

Kotlin
20
star
27

knockout-components

A components library for Knockout.js (3.0 and above)
JavaScript
18
star
28

knockout-paged

Knockout Extension/Plugin for common paged-data scenarios
CSS
16
star
29

knuckles.js

A web application framework built on top of Knockout.js
JavaScript
13
star
30

react-native-animated-navigator

React Native's Navigator implemented with the Animated API
JavaScript
9
star
31

thinking-in-react

Courseware and material for a class on React
JavaScript
9
star
32

understanding-javascript

Courseware and material for a class on JavaScript
JavaScript
9
star
33

knockout-oftype

Some Extensions and Helpers for handling the Constructor pattern in Knockout
JavaScript
8
star
34

react-primitives-art

Cross-platform interface for react ART library
JavaScript
8
star
35

lucene-fluent-query-builder

A convenient Fluent-API around building Lucene.Net queries
C#
7
star
36

shallow-element-equals

Efficient shallow equality algorithm that also allows checks for react element equality of children props
JavaScript
7
star
37

babel-preset-react-native

Babel preset for react native... with a few tweaks
JavaScript
6
star
38

enzyme-example-karma

Example project with React + Enzyme + Karma
JavaScript
5
star
39

react-blogger

minimal isomorphic blog engine built on react
JavaScript
3
star
40

mixinjs

A small library to create factories with useful mixins-based inheritence. Inspired by React's createClass method.
JavaScript
3
star
41

murmur2js

An optimized JavaScript implementation of the MurmurHash algorithm.
JavaScript
3
star
42

MiniBlog

Low-Profile blogging framework built in ASP.Net WebPages Framework
JavaScript
3
star
43

keynote-highlight

Tiny web app to help with syntax highlighting code in keynote
HTML
2
star
44

sivi

Automation Software for Siempre Viva Remote Observatory
C++
2
star
45

lelandrichardson.github.io

Source code for intelligiblebabble.com
JavaScript
2
star
46

viki

Viki - The Visual Wiki Platform
JavaScript
2
star
47

funky.js

A functional programming library for JavaScript
JavaScript
1
star
48

gift-wrap

An asset bundler and minifier (CSS, JS, LESS) for ASP.Net MVC projects
C#
1
star
49

native-navigator

A fully "native" and cross platform Navigator for React Native
Objective-C
1
star
50

leap-gesto

JavaScript Gesture API for Leap Motion
JavaScript
1
star
51

Talks

JavaScript
1
star
52

react-native-windowed-listview

Windowed ListView for React Native (experimental)
1
star
53

module-dep-graph

Automatically track a dependency graph of all commonjs modules in an application
JavaScript
1
star
54

relay-global-immutable-store

playing around with a concept of a global store, similar to Relay, with some offline & eventually-consistent features
JavaScript
1
star