{"id":13687838,"url":"https://github.com/cheeaun/tappable","last_synced_at":"2025-06-29T21:42:06.375Z","repository":{"id":65219961,"uuid":"1783148","full_name":"cheeaun/tappable","owner":"cheeaun","description":"A simple, standalone library to invoke the tap event for touch-friendly web browsers.","archived":false,"fork":false,"pushed_at":"2017-04-17T09:34:40.000Z","size":339,"stargazers_count":310,"open_issues_count":8,"forks_count":35,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-08-03T15:06:49.405Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://cheeaun.github.com/tappable","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheeaun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-05-22T07:54:38.000Z","updated_at":"2024-02-10T18:28:34.000Z","dependencies_parsed_at":"2023-01-16T14:52:31.417Z","dependency_job_id":null,"html_url":"https://github.com/cheeaun/tappable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheeaun%2Ftappable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheeaun%2Ftappable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheeaun%2Ftappable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheeaun%2Ftappable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheeaun","download_url":"https://codeload.github.com/cheeaun/tappable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224266318,"owners_count":17283105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T15:01:01.590Z","updated_at":"2025-05-01T15:33:10.315Z","avatar_url":"https://github.com/cheeaun.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"Tappable\n========\n\nTappable is a simple, standalone library to invoke the **tap** event for touch-friendly web browsers. Currently it's only tested on iOS Mobile Safari as I don't have any other smartphones to test with. The codebase is heavily inspired by Matteo Spinelli's [Remove onClick delay on webkit for iPhone](http://cubiq.org/remove-onclick-delay-on-webkit-for-iphone) and Ryan Fioravanti's [Creating Fast Buttons for Mobile Web Applications](http://code.google.com/mobile/articles/fast_buttons.html).\n\nHere's how you implement the code:\n\n\ttappable('#selector', function(){\n\t\talert('tap');\n\t});\n\nSimple.\n\nWhy 'tap'?\n----------\n\nFirst, it would be wise to read the articles linked above to understand the purpose  of this script. But if you're lazy, take a look at this diagram:\n\n![Diagram 1](https://github.com/cheeaun/tappable/raw/master/diagrams/diagram-1.png)\n\nSo, that's the **tap** event. But wait the minute, I can just use the `touchend` event to *simulate* a tap, right? Wrong, because:\n\n![Diagram 2](https://github.com/cheeaun/tappable/raw/master/diagrams/diagram-2.png)\n\nThis means that once the finger moves, it will not fire the tap event. However, Tappable works in two special cases. First is the *normal* case:\n\n![Diagram 3](https://github.com/cheeaun/tappable/raw/master/diagrams/diagram-3.png)\n\nWhen the page scrolls, the button is not tapped.\n\nThe second case is the `noScroll` mode, where moving your finger on the element will not make the page scroll. This is useful for mobile web apps which might implement their own *fixed* headers or sections on the page.\n\n![Diagram 4](https://github.com/cheeaun/tappable/raw/master/diagrams/diagram-4.png)\n\nThe button is tapped when the finger is on top of the button, even after moving in and out.\n\nDocumentation\n-------------\n\n### Syntax\n\n\ttappable(selector, opts);\n\n### Arguments\n\n1. `selector` - (*string*) The CSS selector expression of element to be tapped.\n2. `opts` - The options object or a function.\n\t* (*object*) The options to be passed.\n\t* (*function*) The function to execute when tapped.\n\n### Options\n\n* noScroll - (*boolean*: defaults to `false`) Whether or not to scroll when *moving* on the element.\n* activeClass - (*string*: defaults to `tappable-active`) A string indicating the *active* class applied to the element.\n* onTap - (*function*) The function to execute when tapped.\n* onStart - (*function*) The function to execute when `touchstart` event is fired.\n* onMove - (*function*) The function to execute when `touchmove` event is fired.\n* onMoveOut - (*function*) The function to execute when touch moves *out* of the element, if `noScroll` is `true`.\n* onMoveIn - (*function*) The function to execute when touch moves back in the element, if `noScroll` is `true`.\n* onEnd - (*function*) The function to execute when `touchend` event is fired.\n* onCancel - (*function*) The function to execute when `touchcancel` event is fired, **or** when touch *moves* if `noScroll` is `false`.\n* allowClick - (*boolean*: defaults to `false`) Whether or not to `preventDefault` the click on the element.\n* boundMargin - (*integer*: defaults to 50) A number indicating the bounding area of tapped region (of the element).\n* noScrollDelay - (*integer*: defaults to 0) A number indicating the delay in ms before 'noScroll' option kicks in.\n* activeClassDelay - (*integer*: defaults to 0) A number indicating the delay in ms before the *active* class is applied.\n* inactiveClassDelay - (*integer*: defaults to 0) A number indicating the delay in ms before the *active* class is removed.\n\n### Instance Object\n\n* el - (*object*) A reference to the bound DOM element.\n* destroy - (*function*) Removes event listeners from the bound DOM element.\n\nDemo\n----\n\nLoad \u003chttp://fiddle.jshell.net/cheeaun/jxwsy/show/light/\u003e in your browser. Edit here \u003chttp://jsfiddle.net/cheeaun/jxwsy/\u003e. Or scan this QR code:\n\n![http://fiddle.jshell.net/cheeaun/jxwsy/show/light/](http://goo.gl/wFhSC.qr)\n\nEvent Delegation (for tagged version 0.1)\n----------------------------------------\n\n**Note: This is no longer needed. The latest code now does event delegation by default**.\n\nHere's a simple example:\n\n\ttappable(document.body || document.getElementsByTagName('body')[0], {\n\t\tonTap: function(e, target){\n\t\t\t// e.target works too\n\t\t\tif (target.tagName.toLowerCase() == 'a'){\n\t\t\t\talert('tap');\n\t\t\t}\n\t\t}\n\t});\n\nFor (almost) every callback function, a second argument which is the target element node, is passed. As a bonus, the event object also have an additional `target` attribute which is the target node (can be any node type, not just element node).\n\nContributing\n------------\n\nFeel free to fork this project! Help and feedback would be appreciated, especially if this could be tested on Android, WebOS or any other touch-friendly browsers, not just mobile ones.\n\nLicense\n-------\n\nTappable is licensed under the [MIT license](http://cheeaun.mit-license.org/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheeaun%2Ftappable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheeaun%2Ftappable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheeaun%2Ftappable/lists"}