{"id":16126061,"url":"https://github.com/rreusser/normalized-interaction-events","last_synced_at":"2026-03-18T18:01:45.518Z","repository":{"id":145193270,"uuid":"69192129","full_name":"rreusser/normalized-interaction-events","owner":"rreusser","description":"Normalized events for desktop and mobile interactions","archived":false,"fork":false,"pushed_at":"2018-04-25T01:14:49.000Z","size":121,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-25T23:36:52.696Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rreusser.github.io/normalized-interaction-events/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rreusser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2016-09-25T21:40:06.000Z","updated_at":"2022-06-21T19:33:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"b986e350-cdd5-4e66-83df-0aec7c531c79","html_url":"https://github.com/rreusser/normalized-interaction-events","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rreusser/normalized-interaction-events","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rreusser%2Fnormalized-interaction-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rreusser%2Fnormalized-interaction-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rreusser%2Fnormalized-interaction-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rreusser%2Fnormalized-interaction-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rreusser","download_url":"https://codeload.github.com/rreusser/normalized-interaction-events/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rreusser%2Fnormalized-interaction-events/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29395906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T00:53:09.511Z","status":"online","status_checked_at":"2026-02-13T02:00:10.076Z","response_time":78,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-09T21:35:05.589Z","updated_at":"2026-02-13T04:02:57.979Z","avatar_url":"https://github.com/rreusser.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# normalized-interaction-events\n\n\u003e Normalized events for desktop and mobile interactions\n\n[![experimental][stability-experimental]][stability-url]\n\u003c!--[![Build Status][travis-image]][travis-url]--\u003e\n\u003c!--[![npm version][npm-image]][npm-url]--\u003e\n\u003c!--[![Dependency Status][david-dm-image]][david-dm-url]--\u003e\n\u003c!--[![Semistandard Style][semistandard-image]][semistandard-url]--\u003e\n\n\n## Introduction\n\nThis module tells you in a consistent manner about the geometry of user interactions, which is perhaps what you really wanted to know when you set out to write a nice graphical interface. All positions are normlized to the inerval `[-1, 1]`, where the left bottom of the element is `[-1, -1]` and the top right is `[1, 1]`.\n\nMouse buttons and mods are output in the style of [mouse-change](https://github.com/mikolalysenko/mouse-change).\n\n## Example\n\n```javascript\nvar normalizedInteractionEvents = require('normalized-interaction-events');\n\nnormalizedInteractionsEvents({\n  element: myel\n}).on('wheel', function (event) {\n  console.log(event);\n});\n\n// =\u003e \n// {\n//   buttons: 0,\n//   mods: {\n//     shift: false,\n//     alt: false,\n//     control: false,\n//     meta: false\n//   },\n//   x0: -0.0129,\n//   y0: -0.923,\n//   x1: -0.0129,\n//   y1: -0.923,\n//   x2: null,\n//   y2: null,\n//   x: -0.129,\n//   y: -0.923,\n//   dx: -0.0011,\n//   dy: -0.0038,\n//   dz: 0,\n//   zoomx: 1,\n//   zoomy: 1,\n//   theta: 0,\n//   dtheta: 0,\n//   originalEvent: MouseEvent {isTrusted: true, screenX: 638, …}\n// }\n```\n\n## Usage\n\n#### `require('normalized-interaction-events')([element])`\n\nCreates an [event-emitter](https://www.npmjs.com/package/event-emitter) to which you may subscribe. `element` defaults to `window`. Event emitter has the following additional methods:\n\n#### `.disable()`\n#### `.enable()`\n\nEnable or disable the emitter by attaching/detaching event listeners. Enabled by default.\n\n### Events\n\nThe emitter emits the following events:\n\n- `wheel`\n- `mousedown`\n- `mousemove`\n- `mouseup`\n- `touchstart`\n- `touchmove`\n- `touchend`\n- `pinchstart`\n- `pinchmove`\n- `pinchend`\n\nThe returned event has the following fields:\n\n- `buttons`: mouse buttons pressed, in the return format of [mouse-change](https://github.com/mikolalysenko/mouse-change).\n- `mods`: modifier keys presed, in the return format of [mouse-change](https://github.com/mikolalysenko/mouse-change).\n- `x`: current x position. For wheel reflects current mouse position. For pinches, reflects average x position of touches.\n- `y`: current y position.\n- `x0`: x position of the corresponding start event (e.g. for a pinchmove event reflects the location of pinchstart)\n- `y0`: y position of the corresponding start event\n- `x1`: x position of the first event\n- `y1`: y position of the first event\n- `x2`: x position of the second event. `null` for mouse or wheel events of when only one touch is occuring.\n- `y2`: y position of the second event. `null` for mouse or wheel events of when only one touch is occuring.\n- `active`: Number of active touches. `0` for passive move events. `1` for dragging, wheel, and touch events, `2` for pinch events. Better than using the mouse depressed state for detecting when to assume a drag since you want to be sure that the drag *originated* within the window.\n- `dx`: change in x position from previous event. For wheel event returns wheel event deltaX.\n- `dy`: change in y position. For wheel event returns wheel event deltaY.\n- `dz`: change in z position. For wheel event returns wheel event deltaY. Is zero except for wheel events (where it's still almost certainly zero).\n- `zoomx`: horizontal zoom factor relative to previous event. `1` reflects no change. For pinch events only. (Interpreting wheel events as a zoom is left to usage.)\n- `zoomy`: vertical zoom factor relative to previous event. `1` reflects no change. For pinch events only.\n- `theta`: angle of the second touch relative to the first. Nonzero for pinch events only. View aspect ratio is taken into account when computing.\n- `dtheta`: change in angle from previous event.\n- `originalEvent`: A reference to the original event. Note that `preventDefault` is *not* called by default.\n\n## License\n\n\u0026copy; 2018 Ricky Reusser. MIT License. Touch handling in this code inherits from [touch-pinch](https://github.com/Jam3/touch-pinch/). See [LICENSE.md](./LICENSE.md) for more details.\n\n\n\u003c!-- BADGES --\u003e\n\n[travis-image]: https://travis-ci.org/rreusser/interaction-events.svg?branch=master\n[travis-url]: https://travis-ci.org//interaction-events\n\n[npm-image]: https://badge.fury.io/js/interaction-events.svg\n[npm-url]: https://npmjs.org/package/interaction-events\n\n[david-dm-image]: https://david-dm.org/rreusser/interaction-events.svg?theme=shields.io\n[david-dm-url]: https://david-dm.org/rreusser/interaction-events\n\n[semistandard-image]: https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square\n[semistandard-url]: https://github.com/Flet/semistandard\n\n\u003c!-- see stability badges at: https://github.com/badges/stability-badges --\u003e\n[stability-url]: https://github.com/badges/stability-badges\n[stability-deprecated]: http://badges.github.io/stability-badges/dist/deprecated.svg\n[stability-experimental]: http://badges.github.io/stability-badges/dist/experimental.svg\n[stability-unstable]: http://badges.github.io/stability-badges/dist/unstable.svg\n[stability-stable]: http://badges.github.io/stability-badges/dist/stable.svg\n[stability-frozen]: http://badges.github.io/stability-badges/dist/frozen.svg\n[stability-locked]: http://badges.github.io/stability-badges/dist/locked.svg\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frreusser%2Fnormalized-interaction-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frreusser%2Fnormalized-interaction-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frreusser%2Fnormalized-interaction-events/lists"}