GithubHelp home page GithubHelp logo

letyougo / tap.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexgibson/tap.js

0.0 2.0 0.0 66 KB

DEPRECATED - A custom 'tap' event JavaScript plugin for touch devices

License: Other

HTML 15.55% JavaScript 84.45%

tap.js's Introduction

Deprecation note

Note: this plugin is now deprecated. While bugs may be fixed for legacy support, no new features will be added. Nearly all modern browsers now provide native solutions for eliminating the 300ms tap delay. Before adding a plugin such as this one to your website, please first stop to consider if it may actually be needed.

tap.js

A custom 'tap' event JavaScript plugin for mobile and tablet web browsers, which eliminates the 300ms delay between a physical 'tap' and the firing of a 'click' event. Uses mouse events as a fallback for browsers that don't support touch.

Installation

  • Download: zip
  • NPM: npm install tap.js
  • Bower: bower install tap.js
  • Git: git clone https://github.com/alexgibson/tap.js

Setup

This component can be used as an AMD module, CommonJS module, or a global.

for AMD module:

define(['./tap'], function(Tap) {
    // ...
});

for CommonJS:

var Tap = require('tap.js');

for global in the browser

<script src="tap.js"></script>

Next create a new Tap instance, passing the element you want to use:

var el = document.getElementById('my-id'),
	myTap = new Tap(el);

You can then start listening for 'tap' events using the regular JavaScript event listener syntax:

el.addEventListener('tap', onTap, false);

function onTap (e) {
	//your code
}

You can stop listening for tap events like so:

el.removeEventListener('tap', onTap, false);

When a Tap instance is created, it adds a couple of event listeners on its element. To remove those listeners and cleanup the Tap instance completely, use its destroy() function:

var myTap = new Tap(el);
myTap.destroy();

Supported web browsers

  • iOS (Safari, Chrome)
  • Android (Browser, Chrome)
  • Firefox OS, Firefox for Android
  • Opera Mobile (Android)
  • All modern desktop browsers (mouse fallback)

jQuery Support

Should you wish to use tap.js with jQuery, there is an optional jQuery wrapper that you can include in your project.

tap.js's People

Contributors

alexgibson avatar iclanzan avatar x3ro avatar danro avatar davidtheclark avatar builtbylane avatar lagden avatar benpptung avatar hapjs avatar psayre23 avatar

Watchers

James Cloos 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.