• Stars
    star
    487
  • Rank 90,352 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 7 years ago

Reviews

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

Repository Details

Fast Touch Events for React

React Fastclick CircleCI

Instantly make your desktop / hybrid apps more responsive on touch devices.

React Fastclick automatically adds fastclick touch events to elements with onClick attributes (and those that require special functionality, such as inputs) to prevent the delay that occurs on some touch devices.

Installation

Use npm to install react-fastclick

npm install react-fastclick

Usage

Initialize react-fastclick in your main javascript file before any of your components are created, and you're done.

Now any calls to onClick or elements with special functionality, such as inputs, will have fast touch events added automatically - no need to write any additional listeners.

ES6

import initReactFastclick from 'react-fastclick';
initReactFastclick();

ES5

var initReactFastclick = require('react-fastclick');
initReactFastclick();

Notes

  1. The event triggered on touch devices is a modified touchend event. This means that it may have some keys that are unusual for a click event.

In order to simulate a click as best as possible, this event is populated with the following keys / values. All positions are taken from the last know touch position.

{
  // Simulate left click
  button: 0,
  type: 'click',
  // Additional key to tell the difference between
  // a regular click and a fastclick
  fastclick: true,
  // From touch positions
  clientX,
  clientY,
  pageX,
  pageY,
  screenX,
  screenY
}
  1. On some devices the elements flicker after being touched. This can be prevented by setting the css property -webkit-tap-highlight-color to transparent. Either target html, body (to prevent the flickering on all elements) or target the specific element you don't want to flicker e.g. button.

    html, body {
      -webkit-tap-highlight-color: transparent;
    }

Support

React Fastclick 3.x.x has been tested with React 15, but should support older versions also.

More Repositories

1

react-reorder

Drag & drop, touch enabled, reorderable / sortable list, React component
JavaScript
219
star
2

canvasimo

An HTML5 canvas drawing library, with 150+ useful methods, jQuery-like fluent interface, and cross-browser compatibility enhancements.
TypeScript
16
star
3

react-monkey-patching

Some useful examples of monkey patching React
JavaScript
9
star
4

slik

Animation / tweening library, ideal for use with HTML5 canvas and or React
JavaScript
7
star
5

react-highlight-updates

Visually highlight when React components are updated
TypeScript
7
star
6

istanbul-no-coverage

Demonstrate "No coverage information was collected" issue
JavaScript
6
star
7

antler

Directory structure linter
TypeScript
5
star
8

tsurl

Type safe URL construction and deconstruction
TypeScript
4
star
9

tsb

Dead simple TypeScript bundler, watcher, dev server, transpiler, and polyfiller
TypeScript
3
star
10

abc

DEPRECATED: Angular Bound Charts
JavaScript
3
star
11

jargs

Simple node arg parser with explicit tree structure schema
JavaScript
3
star
12

async-2023-08-03-the-power-of-typescript

Various demos to show the true power of TypeScript
TypeScript
2
star
13

react-shallow-renderer

A shallow renderer for React components
TypeScript
2
star
14

react-canvas-spark-line

Simple canvas SparkLine React component
TypeScript
2
star
15

e-liquid-calculator

Calculate the e-liquid that you can make from base components
JavaScript
2
star
16

licons

A group of icons made from HTML & CSS that can transition between each other
CSS
2
star
17

sentry-events

CLI to list Sentry events
JavaScript
1
star
18

jsdoodle

Simple javascript editor with preview & console
JavaScript
1
star
19

csscraft

Minecraft with CSS
JavaScript
1
star
20

crabs

πŸ¦€πŸ¦€ Run multiple crab processes with a single command
TypeScript
1
star
21

the-speed-of-write

Demo project for Async talk: The Speed of Write
TypeScript
1
star
22

eslint-config-jakesidsmith

A collection of my common eslint configurations
JavaScript
1
star
23

watch-less-do-more

Watch less files and their dependency tree for changes & automatically recompile
JavaScript
1
star
24

3d-canvas-renderer

Messing around with rendering 3D objects on a 2D canvas
JavaScript
1
star