{"id":13448604,"url":"https://github.com/GoogleChromeLabs/pointer-tracker","last_synced_at":"2025-03-22T09:31:29.658Z","repository":{"id":33222914,"uuid":"152469265","full_name":"GoogleChromeLabs/pointer-tracker","owner":"GoogleChromeLabs","description":"Track mouse/touch/pointer events for a given element.","archived":false,"fork":false,"pushed_at":"2024-09-24T08:30:28.000Z","size":138,"stargazers_count":189,"open_issues_count":9,"forks_count":24,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-18T12:12:24.205Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoogleChromeLabs.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-10-10T18:16:47.000Z","updated_at":"2025-02-13T05:19:49.000Z","dependencies_parsed_at":"2024-01-14T06:22:46.783Z","dependency_job_id":"10c3a404-4251-40c6-8df5-bfa0f41be3c8","html_url":"https://github.com/GoogleChromeLabs/pointer-tracker","commit_stats":{"total_commits":36,"total_committers":5,"mean_commits":7.2,"dds":"0.13888888888888884","last_synced_commit":"f3d4e7902cc02daf83337c658850976f74bc62fb"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fpointer-tracker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fpointer-tracker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fpointer-tracker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fpointer-tracker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoogleChromeLabs","download_url":"https://codeload.github.com/GoogleChromeLabs/pointer-tracker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244937751,"owners_count":20535124,"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-07-31T05:01:50.232Z","updated_at":"2025-03-22T09:31:28.904Z","avatar_url":"https://github.com/GoogleChromeLabs.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Touch Gestures"],"sub_categories":["Reactive Programming"],"readme":"# PointerTracker\n\nTrack mouse/touch/pointer events for a given element.\n\n## API\n\n### PointerTracker\n\n```js\nimport PointerTracker from 'pointer-tracker';\n\nconst pointerTracker = new PointerTracker(element, {\n  start(pointer, event) {\n    // Called when a pointer is pressed/touched within the element.\n    //\n    // pointer - The new pointer. This pointer isn't included in this.currentPointers or\n    // this.startPointers yet.\n    //\n    // event - The event related to this pointer.\n    //\n    // Return true from this callback if you're interested in further events about this pointer,\n    // such as 'move' and 'end'.\n  },\n  move(previousPointers, changedPointers, event) {\n    // Called when pointers have moved.\n    //\n    // previousPointers - The state of the pointers before this event. This contains the same number\n    // of pointers, in the same order, as this.currentPointers and this.startPointers.\n    //\n    // changedPointers - The pointers that have changed since the last move callback.\n    //\n    // event - The event related to the pointer changes.\n  },\n  end(pointer, event, cancelled) {\n    // Called when a pointer is released.\n    //\n    // pointer - The final state of the pointer that ended. This pointer is now absent from\n    // this.currentPointers and this.startPointers.\n    //\n    // event - The event related to this pointer.\n    //\n    // cancelled - True if the event was cancelled. Actions are cancelled when the OS takes over\n    // pointer events, for actions such as scrolling.\n  },\n  // Avoid pointer events in favour of touch and mouse events?\n  //\n  // Even if the browser supports pointer events, you may want to force the browser to use\n  // mouse/touch fallbacks, to work around bugs such as\n  // https://bugs.webkit.org/show_bug.cgi?id=220196.\n  //\n  // The default is false.\n  avoidPointerEvents: false,\n  // Use raw pointer updates? Pointer events are usually synchronised to requestAnimationFrame.\n  // However, if you're targeting a desynchronised canvas, then faster 'raw' updates are better.\n  //\n  // This feature only applies to pointer events. The default is false.\n  rawUpdates: false,\n});\n\n// State of the tracked pointers when they were pressed/touched.\npointerTracker.startPointers;\n// Latest state of the tracked pointers. Contains the same number of pointers, and in the same order\n// as this.startPointers.\npointerTracker.currentPointers;\n// Remove all listeners. Call this when you're done tracking.\npointerTracker.stop();\n```\n\n### Pointer\n\n```js\nconst pointer = pointerTracker.currentPointers[0];\n\n// x offset from the top of the document\npointer.pageX;\n// y offset from the top of the document\npointer.pageY;\n// x offset from the top of the viewport\npointer.clientX;\n// y offset from the top of the viewport\npointer.clientY;\n// Unique ID for this pointer\npointer.id;\n// The platform object used to create this Pointer\npointer.nativePointer;\n// Returns an expanded set of Pointers for high-resolution inputs.\nconst pointers = pointer.getCoalesced();\n```\n\n## Demo\n\n[A simple painting app](https://pointer-tracker-demo.glitch.me/) ([code](https://glitch.com/edit/#!/pointer-tracker-demo?path=public/index.html)).\n\n## Files\n\n- `lib/index.ts` - Original TypeScript.\n- `dist/PointerTracker.mjs` - JS module. Default exports PointerTracker.\n- `dist/PointerTracker.js` - UMD JS. Exposes PointerTracker on the global by default.\n- `dist/PointerTracker-min.js` - Minified UMD JS. ~900 bytes brotli'd.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoogleChromeLabs%2Fpointer-tracker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGoogleChromeLabs%2Fpointer-tracker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoogleChromeLabs%2Fpointer-tracker/lists"}