{"_id":"teeny-tap","_rev":"4-8bb6b049107284e0777dd8a87df68dbb","name":"teeny-tap","description":"Listen for both clicks and click-like touches (not scrolls or drags)","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"teeny-tap","version":"0.1.0","description":"Listen for both clicks and click-like touches (not scrolls or drags)","main":"index.js","scripts":{"demo-dev":"watchify demo/demo.js -o demo/demo-bundle.js -v & http-server demo","demo-bundle":"browserify demo/demo.js > demo/demo-bundle.js","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/davidtheclark/teeny-tap.git"},"keywords":["tap","click","mobile","touch","event","listener"],"author":{"name":"David Clark"},"license":"MIT","bugs":{"url":"https://github.com/davidtheclark/teeny-tap/issues"},"homepage":"https://github.com/davidtheclark/teeny-tap#readme","devDependencies":{"browserify":"13.0.0","http-server":"0.8.5","watchify":"3.7.0"},"gitHead":"e6f0c895e218aaabc3e93dfe40811e5bcbef3e76","_id":"teeny-tap@0.1.0","_shasum":"c1b68da7aa35dfded7ef61b50b3e7b0ffcc4cdba","_from":".","_npmVersion":"3.5.3","_nodeVersion":"5.5.0","_npmUser":{"name":"davidtheclark","email":"david.dave.clark@gmail.com"},"dist":{"shasum":"c1b68da7aa35dfded7ef61b50b3e7b0ffcc4cdba","tarball":"https://registry.npmjs.org/teeny-tap/-/teeny-tap-0.1.0.tgz","integrity":"sha512-0eeTMaYoXbwwgYBChenKtBRZhuCbMNy+Yiyh1dnRG8LjU/f4zcDqzdpRxvVtn+o8uR7ki194K8uSTUCZiEqNVA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCTc+h/sD8vV7fR9APBAoQ0T0i+BGwLZJ23nbyUXl8fbAIgfb2TZU/LyfLAJ7wY/dTQZxA5DmKtbQuvPdVEvrb8Bos="}]},"maintainers":[{"name":"davidtheclark","email":"david.dave.clark@gmail.com"}]},"0.2.0":{"name":"teeny-tap","version":"0.2.0","description":"Listen for both clicks and click-like touches (not scrolls or drags)","main":"index.js","scripts":{"demo-dev":"watchify demo/demo.js -o demo/demo-bundle.js -v & http-server demo","demo-bundle":"browserify demo/demo.js > demo/demo-bundle.js","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/davidtheclark/teeny-tap.git"},"keywords":["tap","click","mobile","touch","event","listener"],"author":{"name":"David Clark"},"license":"MIT","bugs":{"url":"https://github.com/davidtheclark/teeny-tap/issues"},"homepage":"https://github.com/davidtheclark/teeny-tap#readme","devDependencies":{"browserify":"13.0.0","http-server":"0.8.5","watchify":"3.7.0"},"gitHead":"80d08cdbb1a038218ce6bc13c7f001560b4c65dc","_id":"teeny-tap@0.2.0","_shasum":"167e645182d06ac222d62bb2ab67947a70a58a68","_from":".","_npmVersion":"3.7.1","_nodeVersion":"5.5.0","_npmUser":{"name":"davidtheclark","email":"david.dave.clark@gmail.com"},"dist":{"shasum":"167e645182d06ac222d62bb2ab67947a70a58a68","tarball":"https://registry.npmjs.org/teeny-tap/-/teeny-tap-0.2.0.tgz","integrity":"sha512-HnA3I2sxRQe/SZgQTQgQvvA17DhfzhBJ1LfSOXZ5VUTbxGLvnAqUef84ZGNNSEbk1ZMEIDeghTHZagJ7LifAgg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC21Km2eJ9LFEIySpPb+iKU6WzMexyjs7Hie/m3IhEDlgIhAJSeD6VflIwatnh+JW8TMBJVHficYoPkxaDCNSNAGKtp"}]},"maintainers":[{"name":"davidtheclark","email":"david.dave.clark@gmail.com"}],"_npmOperationalInternal":{"host":"packages-9-west.internal.npmjs.com","tmp":"tmp/teeny-tap-0.2.0.tgz_1455371654286_0.34019159781746566"}}},"readme":"# teeny-tap\n\n**Status: Experimental, Under Active Development**\n\nListen for both clicks and click-like touches (not scrolls or drags).\n\nThis library is very small and simple and focused, without any dependencies.\nIt is not a touch gesture library or a complete fastclick-style solution.\nPlenty of similar libraries exist, but none of them seemed exactly right for\nmy simple needs. For more about the purpose of the library, read [\"Why?\"](#why).\n\nThis library is heavily inspired by [tap.js](https://github.com/alexgibson/tap.js),\nwhich is no longer maintained.\n\n**[Check out the demo](http://davidtheclark.github.io/teeny-tap/demo/).**\n\n(If the demo works on your phone, would you mind tweeting me your specs,\n`@davidtheclark`? That way I can list the devices where we know it works.\nAnd of course let me know if you find any bugs!)\n\n## Installation\n\n```\nnpm install teeny-tap\n```\n\nYou will need to be compiling CommonJS modules (browserify or webpack).\n\n### Browser Support\n\nIE9+ and everything help, I hope. Testing underway.\n(If you can help out by trying the demo on your mobile device, please do!)\n\n## Usage\n\n```js\nvar createTapListener = require('teeny-tap');\n\nvar docTapListener = createTapListener(document.documentElement, function(e) {\n  console.log('A tap happened!');\n});\n\n// ...\ndocTapListener.remove();\n```\n\nThat's it. Very simple. You create and remove listeners.\n\n### API\n\n#### `var tapListenerInstance = createTapListener(element, callback[, useCapture])`\n\nAdds a tap listener on `element`, using `addEventListener()`.\nWhen there's a tap, `callback` is invoked with\nthe relevant `event` as its argument (either a `click` or `touchend` event).\n\n**Returns an object with a `remove` function, for removing the listener.**\n\n#### `tapListenerInstance.remove()`\n\nRemove the listener that you added when you created `tapListenerInstance`.\n\n## Why?\n\nFor\n[react-aria-menubutton](https://github.com/davidtheclark/react-aria-menubutton),\nI need to close an open menu when the user taps/clicks outside of it.\n\nThe click event wasn't reliable: mobile Safari screws it up.\nSo I needed to **distinguish, on touch devices, between *touches\nthat are scrolling or dragging* and *touches that are clicking*,\nin situations where the regular `click` event doesn't work**.\nExisting solutions that I found weren't satisfactory for a few reasons:\n\n- jQuery or other dependencies I didn't want or need.\n\n- Many just threw in a `touchstart` or `touchend`\nlistener, in addition to the click; but that alone won't distinguish\nbetween tapping and scrolling/dragging, so it's insufficient.\nThe menu might close when you, say, scroll down in order to see more of it.\nEgad!\n\n- One solution to the detect-clicks-outside-an-element problem is to add an\nunderlay that covers the page, beneath the element, and listen for clicks on that.\nHowever, this prevents the click from getting through and actually\n*doing* something; so if I click a link outside the open menu,\nthat click only closes the menu, and I have to click *again* to\ngo where I wanted to go. Non-optimal.\n\n- A number of solutions just use `click` events, which won't\nwork on most browsers on most iPhones and iPads, due to\nmobile Safari's unique and unpleasant handling of click events.\n\n- Some went the other way, and had more fine-tuning than I want or need.\n\n[tap.js](https://github.com/alexgibson/tap.js) pretty much provided exactly what I needed,\nbut that library is no longer maintained so I made this one to carry the torch,\nto fill the need.\n\nBut know that *I do not like that this exists, do not want it to need to exist*.\nIf you know of a way to accomplish the same goal without this library,\nplease let me know!\n","maintainers":[{"name":"davidtheclark","email":"david.dave.clark@gmail.com"}],"time":{"modified":"2022-06-27T04:27:54.815Z","created":"2016-01-26T00:05:20.580Z","0.1.0":"2016-01-26T00:05:20.580Z","0.2.0":"2016-02-13T13:54:15.951Z"},"homepage":"https://github.com/davidtheclark/teeny-tap#readme","keywords":["tap","click","mobile","touch","event","listener"],"repository":{"type":"git","url":"git+https://github.com/davidtheclark/teeny-tap.git"},"author":{"name":"David Clark"},"bugs":{"url":"https://github.com/davidtheclark/teeny-tap/issues"},"license":"MIT","readmeFilename":"README.md"}