{"id":23053379,"url":"https://github.com/component/tap-event","last_synced_at":"2025-08-15T03:32:36.077Z","repository":{"id":12077361,"uuid":"14664803","full_name":"component/tap-event","owner":"component","description":"Create tap event listeners","archived":false,"fork":false,"pushed_at":"2015-11-13T20:04:54.000Z","size":161,"stargazers_count":17,"open_issues_count":4,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-12T01:10:28.083Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/component.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-24T16:43:39.000Z","updated_at":"2022-11-24T20:12:29.000Z","dependencies_parsed_at":"2022-09-20T23:30:25.561Z","dependency_job_id":null,"html_url":"https://github.com/component/tap-event","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Ftap-event","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Ftap-event/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Ftap-event/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Ftap-event/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/component","download_url":"https://codeload.github.com/component/tap-event/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229890297,"owners_count":18140075,"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-12-16T00:17:52.889Z","updated_at":"2024-12-16T00:17:53.294Z","avatar_url":"https://github.com/component.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tap Event\n\nMake your `touchstart` event listeners into a `tap` event listener!\n\nWhat is \"correct\" behavior? The `tap` event:\n\n- shouldn't be triggered until the user removes his/her finger from the surface of the screen.\n- shouldn't be triggered when the user moves his/her finger at all (ie it should not interfere with drag events).\n- shouldn't be triggered if there's ever more than a single finger on the surface at all.\n- should never trigger the `click` event.\n\n## API\n\n```js\nvar tap = require('tap-event')\n\nvar el = document.querySelector('#container')\n\n// the event you want to handle\nfunction changeLocation(e) {\n  // e.preventDefault() is already called!\n  location.href = this.href\n}\n\n// wrap the listener\nvar listener = tap(changeLocation)\n\n// listen to `touchstart`\nel.addEventListener('touchstart', listener)\n\n// remove the listener\nel.removeEventListener('touchstart', listener)\n```\n\nor, more succinctly:\n\n```js\ndocument.querySelector('#container').addEventListener('touchstart', tap(function (e) {\n  location.href = this.href\n}))\n```\n\nTo set a custom timeout (default is `200ms`), you have two options:\n\n```js\n// set globally\ntap.timeout = 300\n\n// set per instance\ntap(function (e) {\n\n}, {\n  timeout: 300\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Ftap-event","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomponent%2Ftap-event","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Ftap-event/lists"}