{"id":18389568,"url":"https://github.com/anseki/pointer-event","last_synced_at":"2025-04-07T02:34:32.436Z","repository":{"id":32602350,"uuid":"137885575","full_name":"anseki/pointer-event","owner":"anseki","description":"Event Controller for mouse and touch interfaces","archived":false,"fork":false,"pushed_at":"2025-02-22T02:56:21.000Z","size":641,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T13:06:27.591Z","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/anseki.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-19T12:00:13.000Z","updated_at":"2025-02-28T16:53:03.000Z","dependencies_parsed_at":"2025-03-08T01:01:30.229Z","dependency_job_id":"46fef007-c07e-499c-b2df-c6d35da56fe3","html_url":"https://github.com/anseki/pointer-event","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fpointer-event","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fpointer-event/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fpointer-event/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fpointer-event/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anseki","download_url":"https://codeload.github.com/anseki/pointer-event/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247583493,"owners_count":20962042,"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-11-06T01:43:45.198Z","updated_at":"2025-04-07T02:34:27.427Z","avatar_url":"https://github.com/anseki.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PointerEvent\n\nEvent Controller for mouse and touch interfaces\n\n## Usage\n\n```js\nvar pointerEvent = new PointerEvent(),\n\n  // startHandlerId which is used for adding/removing to element is returned.\n  startHandlerId = pointerEvent.regStartHandler(function(pointerXY) {\n    console.log('[START]');\n    console.dir(pointerXY); // Object having `clientX` and `clientY`.\n    this.options.stopPropagation = false; // Access to current instance via `this`.\n    return true; // If it returns `false`, the starting is canceled.\n  });\n\n// When `mousedown` or `touchstart` is fired on this element, the registered start-handler is called.\npointerEvent.addStartHandler(document.getElementById('trigger'), startHandlerId);\n\n// When `mousemove` or `touchmove` is fired on this element, this move-handler is called.\n// By default, the handler is called via `requestAnimationFrame`. `true` for third argument disables this.\npointerEvent.addMoveHandler(document, function(pointerXY) {\n  console.log('[MOVE]');\n  console.dir(pointerXY); // Object having `clientX` and `clientY`.\n  this.options.stopPropagation = false; // Access to current instance via `this`.\n}/*, true */);\n\n// When `mouseup` or `touchend` is fired on this element, this end-handler is called.\npointerEvent.addEndHandler(document, function(pointerXY) {\n  console.log('[END]');\n  console.dir(pointerXY); // Object having `clientX` and `clientY`.\n  this.options.stopPropagation = false; // Access to current instance via `this`.\n});\n\n// When `touchcancel` is fired on this element, this cancel-handler is called.\npointerEvent.addCancelHandler(document, function() {\n  console.log('[CANCEL]');\n  console.log(this.options.stopPropagation); // Access to current instance via `this`.\n});\n\n// ============================================================================\n\ndocument.getElementById('move-button').addEventListener('click', function() {\n  // Emulate the `move` that is done when `mousemove` or `touchmove` is fired.\n  pointerEvent.move(); // pointerXY can be passed.\n}, false);\n\ndocument.getElementById('end-button').addEventListener('click', function() {\n  // Emulate the `end` that is done when `mouseup` or `touchend` is fired.\n  pointerEvent.end(); // pointerXY can be passed.\n}, false);\n\ndocument.getElementById('cancel-button').addEventListener('click', function() {\n  // Emulate the `cancel` that is done when `touchcancel` is fired.\n  pointerEvent.cancel();\n}, false);\n\n// ============================================================================\n\n// Remove the added start-handler from this element.\npointerEvent.removeStartHandler(document.getElementById('trigger'), startHandlerId);\n\n// Unregister the registered start-handler.\npointerEvent.unregStartHandler(startHandlerId);\n\n// ============================================================================\n\n// Options:\n// preventDefault {boolean} [true] - Call `event.preventDefault()` if it is `true`.\n// stopPropagation {boolean} [true] - Call `event.stopPropagation()` if it is `true`.\nvar pointerEvent = new PointerEvent({stopPropagation: false}); // Don't call that.\n\n// ============================================================================\n\n// addEventListener with specific option.\nPointerEvent.addEventListenerWithOptions(target, type, listener, options);\n\n// Emulate `click` event via `touchend` event.\n// Default emulator is disabled by `event.preventDefault()`.\n// Also, this has to be called before attaching listeners that call `event.preventDefault()` (e.g. `addStartHandler()`).\nPointerEvent.initClickEmulator(element, moveTolerance, timeTolerance);\n// `Event` object that is passed to listeners has `emulated` property that is `true`.\n\n// Emulate `dblclick` event via `touchend` event.\n// Default emulator is disabled by `event.preventDefault()`.\n// Also, this has to be called before attaching listeners that call `event.preventDefault()` (e.g. `addStartHandler()`).\nPointerEvent.initDblClickEmulator(element, moveTolerance, timeTolerance);\n// `Event` object that is passed to listeners has `emulated` property that is `true`.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanseki%2Fpointer-event","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanseki%2Fpointer-event","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanseki%2Fpointer-event/lists"}