{"id":13602368,"url":"https://github.com/hammerjs/touchemulator","last_synced_at":"2025-05-16T17:08:33.779Z","repository":{"id":18817857,"uuid":"22032643","full_name":"hammerjs/touchemulator","owner":"hammerjs","description":"Emulate touch input on your desktop","archived":false,"fork":false,"pushed_at":"2022-11-17T03:11:38.000Z","size":61,"stargazers_count":397,"open_issues_count":17,"forks_count":106,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-05-10T22:48:04.194Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://hammerjs.github.io/touch-emulator","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"worldmaker18349276/test","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hammerjs.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":"2014-07-20T12:22:20.000Z","updated_at":"2025-04-24T00:55:10.000Z","dependencies_parsed_at":"2022-09-25T02:40:28.520Z","dependency_job_id":null,"html_url":"https://github.com/hammerjs/touchemulator","commit_stats":null,"previous_names":["hammerjs/emulator"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hammerjs%2Ftouchemulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hammerjs%2Ftouchemulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hammerjs%2Ftouchemulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hammerjs%2Ftouchemulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hammerjs","download_url":"https://codeload.github.com/hammerjs/touchemulator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254573589,"owners_count":22093731,"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-01T18:01:21.288Z","updated_at":"2025-05-16T17:08:33.720Z","avatar_url":"https://github.com/hammerjs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Gesture","Gesture [🔝](#readme)","UI","手势"],"sub_categories":["Other","其它"],"readme":"Touch Emulator\n========\n\nEmulate multi-touch input on your desktop. Triggers touch events as\n[specified by W3C](http://www.w3.org/TR/touch-events). Press the `shift` key to pinch and rotate!\n\n- [Example with Hammer.js](http://rawgit.com/hammerjs/touchemulator/master/tests/manual/hammer.html)\n- [Example with Leaflet Maps](http://rawgit.com/hammerjs/touchemulator/master/tests/manual/leaflet.html)\n- [View webpage](http://hammerjs.github.io/touch-emulator)\n\n## Install\nDownload the script from this repo, via Bower:\n\n```bash\nbower install hammer-touchemulator\n```\n\nor NPM:\n\n```bash\nnpm install hammer-touchemulator\n```\n\n## How to use\nInclude the javascript file, and call the `Emulator()` function before any other libraries that do something with the \ntouch input. It will set some fake properties to spoof the touch detection of some libraries, and triggers `touchstart`, `touchmove` and `touchend` events on the mouse target.\n \n````html\n\u003cscript src=\"touch-emulator.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e TouchEmulator(); \u003c/script\u003e\n````\n\n````js\nfunction log(ev) {\n console.log(ev);\n}\n\ndocument.body.addEventListener('touchstart', log, false);\ndocument.body.addEventListener('touchmove', log, false);\ndocument.body.addEventListener('touchend', log, false);\n````\n\nAlso, the script includes polyfills for `document.createTouch` and `document.createTouchList`.\n\n## How it works\nIt listens to the `mousedown`, `mousemove` and `mouseup` events, and translates them to touch events. If the mouseevent\nhas the `shiftKey` property to `true`, it enables multi-touch. \n\nThe script also prevents the following mouse events on the page: \n`mousedown`, `mouseenter`, `mouseleave`, `mousemove`, `mouseout`, `mouseover` and `mouseup`.\n\n## Web platform tests\nThe script has been tested with the [w3c web platform tests](/tests/web-platform-tests/touch-events) and passes all tests,  except these;\n- *assert_true: event is a TouchEvent event expected true got false*\n  - We trigger an event of the type `Event`\n- *assert_equals: touch list is of type TouchList expected \"[object TouchList]\" but got \"[object Array]\"*\n- *assert_equals: touch is of type Touch expected \"[object Touch]\" but got \"[object Object]\"*\n\n## Bookmarklet\n````js\njavascript:!function(a){var b=a.createElement(\"script\");b.onload=function(){TouchEmulator()},b.src=\"//cdn.rawgit.com/hammerjs/touchemulator/0.0.2/touch-emulator.js\",a.body.appendChild(b)}(document);\n````\n\n## Options\n#### TouchEmulator.template = Function(touch)\nChange the css properties of the rendered touches.\n\n#### TouchEmulator.multiTouchOffset = 75\nThe distance between the two touch points when entering the *multi-touch zone*.\n\n#### TouchEmulator.ignoreTags = [...]\nThe names of HTML tags that shouldn't swallow mouse events (default: `['TEXTAREA', 'INPUT']`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhammerjs%2Ftouchemulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhammerjs%2Ftouchemulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhammerjs%2Ftouchemulator/lists"}