Git Product home page Git Product logo

touch-action's Introduction

touch-action

Disable 300ms delay on mobile using CSS touch-action or asynchronously download FastClick as polyfill.

CSS touch-action property allows eliminate the 300ms delay between a physical tap and the firing of a click event on mobile browsers. It's supported by all major browsers including Safari 9.3. Therefore, there's no reason to always use FastClick and include it to javascript bundle.

This library is just 17 lines of code and 14x smaller than FastClick (2.68Kb vs 0.2Kb). It checks support of CSS touch-action, and sets touch-action: manipulation to document body. When touch-action property is not supported, it asynchronously downloads FastClick from CDN and use FastClick.attach(document.body) as polyfill.

This module is inspired by gajus's gist.

Installation

npm install touch-action --save
bower install touch-action

Standalone version available as dist/touch-action.min.js.

<script src="touch-action.min.js"></script>
<script>window.touchAction()</script>

Example

import touchAction from 'touch-action'

// use default behavior and download FastClick from CDN when needed
// https://cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js
touchAction()

// use your own copy of FastClick
touchAction({ src: '/assets/fastclick.min.js' })

touchAction(opts)

Init touch-action or download and attach FastClick.

Available options:

License

MIT

touch-action's People

Contributors

alekseykulikov avatar hakubo avatar jabez128 avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.