├── .babelrc ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .npmignore ├── .travis.yml ├── LICENSE ├── README.md ├── examples ├── smartphone-dashboard │ ├── Dashboard.react.js │ ├── index.html │ ├── index.js │ └── package.json └── webpack.config.js ├── package.json └── src ├── CustomGesture.react.js ├── Draggable.react.js ├── Holdable.react.js ├── Swipeable.react.js ├── TouchHandler.js ├── circleMath.js ├── computeDeltas.js ├── computePositionStyle.js ├── convertToDefaultsObject.js ├── defineHold.js ├── defineSwipe.js ├── gestureLevenshtein.js ├── gestureMoves.js ├── index.js └── tests ├── CustomGesture.react.spec.js ├── Draggable.react.spec.js ├── Holdable.react.spec.js ├── Swipeable.react.spec.js ├── computeDeltas.spec.js ├── computePositionStyle.spec.js ├── gestureLevenshtein.spec.js ├── helpers.js ├── index.spec.js └── setup.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015", 4 | "stage-2" 5 | ], 6 | "plugins": [ 7 | "transform-react-jsx", 8 | "transform-es2015-modules-commonjs", 9 | "transform-class-properties" 10 | ], 11 | "env": { 12 | "test": { 13 | "plugins": ["rewire"] 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | webpack.config*.js 2 | node_modules 3 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint-config-airbnb", 3 | "parser": "babel-eslint", 4 | "env": { 5 | "browser": true, 6 | "mocha": true, 7 | }, 8 | rules: { 9 | "arrow-body-style": 0, // this is a little overzealous 10 | "no-use-before-define": ["error", "nofunc"], 11 | "space-infix-ops": 0, // enforcement is too broad currently 12 | "quotes": 0, 13 | "no-unused-expressions": ["error", { "allowShortCircuit": true }], 14 | "array-bracket-spacing": 0, 15 | "object-curly-spacing": 0, 16 | "comma-dangle": ["error", "always-multiline"], 17 | "react/sort-comp": 0, // I need to fiddle with this a bit 18 | "react/prop-types": 0 // little buggy right now (https://github.com/yannickcr/eslint-plugin-react/issues/494) 19 | }, 20 | "plugins": [ 21 | "react" 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib 2 | node_modules 3 | .DS_Store 4 | npm-debug.log 5 | coverage 6 | build.js* 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | coverage 2 | .babelrc 3 | .eslint* 4 | .npmignore 5 | .travis.yml 6 | build.js* 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - "5" 5 | - "node" 6 | 7 | script: 8 | - npm run lint 9 | - npm test 10 | 11 | after_success: 12 | - npm run test:cov 13 | - npm run test:codecov 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Phil Aquilina 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React-Touch 2 | [![Build Status](https://img.shields.io/travis/phil303/react-touch/master.svg?style=flat)](https://travis-ci.org/phil303/react-touch) 3 | [![codecov.io](https://codecov.io/github/phil303/react-touch/coverage.svg?branch=master)](https://codecov.io/github/phil303/react-touch?branch=master) 4 | [![NPM Version](https://img.shields.io/npm/v/react-touch.svg?style=flat)](https://www.npmjs.com/package/react-touch) 5 | 6 | React-Touch is a set of wrapper components that handle touch interactions in a more declarative way, abstracting out and giving you hooks into behaviors such as dragging, holding, swiping, and custom gestures. React-Touch also works with mouse events as well. 7 | 8 | Here's a quick example of the API. 9 | 10 | ```jsx 11 | import { Holdable } from 'react-touch'; 12 | 13 | ({ holdProgress }) =>