{"id":18389564,"url":"https://github.com/anseki/anim-event","last_synced_at":"2025-04-06T09:07:19.076Z","repository":{"id":50787678,"uuid":"66008297","full_name":"anseki/anim-event","owner":"anseki","description":"Event Manager for Animation","archived":false,"fork":false,"pushed_at":"2025-02-22T03:08:13.000Z","size":180,"stargazers_count":34,"open_issues_count":0,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T08:11:27.013Z","etag":null,"topics":["animation","debounce","drag","event","event-listener","mousemove","performance","requestanimationframe","resize","scroll","throttle"],"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}},"created_at":"2016-08-18T15:22:42.000Z","updated_at":"2025-02-28T16:50:51.000Z","dependencies_parsed_at":"2023-02-08T05:15:30.424Z","dependency_job_id":null,"html_url":"https://github.com/anseki/anim-event","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fanim-event","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fanim-event/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fanim-event/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fanim-event/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anseki","download_url":"https://codeload.github.com/anseki/anim-event/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457800,"owners_count":20941906,"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":["animation","debounce","drag","event","event-listener","mousemove","performance","requestanimationframe","resize","scroll","throttle"],"created_at":"2024-11-06T01:43:45.151Z","updated_at":"2025-04-06T09:07:19.059Z","avatar_url":"https://github.com/anseki.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AnimEvent\n\n[![npm](https://img.shields.io/npm/v/anim-event.svg)](https://www.npmjs.com/package/anim-event) [![GitHub issues](https://img.shields.io/github/issues/anseki/anim-event.svg)](https://github.com/anseki/anim-event/issues) [![dependencies](https://img.shields.io/badge/dependencies-No%20dependency-brightgreen.svg)](package.json) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nSuper Simple Event Manager for Animation\n\nSome DOM events (e.g. `scroll`, `resize`, `mousemove`, `drag`, etc.) are fired too frequently.  \nThe listening to those events for animation is performance degradation.  \nAnimEvent controls timing of calling event listeners with [`requestAnimationFrame`](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame) (or 60fps in a web browser that doesn't support it).\n\nAnimEvent works like [lodash's `throttle` function](https://lodash.com/docs#throttle), but it uses `requestAnimationFrame` that is more optimized for animation, instead of \"wait-time\".\n\nExample: Open a file `test/test.html` by web browser.\n\n## Usage\n\nLoad AnimEvent into your web page.\n\n```html\n\u003cscript src=\"anim-event.min.js\"\u003e\u003c/script\u003e\n```\n\nTo register your event listener, pass `AnimEvent.add(listener)` instead of `listener` to [`addEventListener` method](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener).\n\nFor example, replace first code with second code:\n\n```js\nwindow.addEventListener('scroll', listener, false);\n```\n\n```js\nwindow.addEventListener('scroll', AnimEvent.add(listener), false);\n```\n\nThen `listener` is called when the window is scrolled, with optimized timing for animation. Superfluous fired events are ignored.\n\n## Methods\n\n### `AnimEvent.add`\n\n```js\nwrappedListener = AnimEvent.add(listener)\n```\n\nAdd an event listener that is controlled by AnimEvent.  \nPass a returned `wrappedListener` to `addEventListener` method.\n\nA listener that has already been added can not be added.  \nFor example, use one listener for multiple events:\n\n```js\nvar listener = AnimEvent.add(function(event) { console.log(event); });\nwindow.addEventListener('scroll', listener, false);\nwindow.addEventListener('resize', listener, false);\n```\n\n### `AnimEvent.remove`\n\n```js\nAnimEvent.remove(listener)\n```\n\nRemove an event listener that was added by [`AnimEvent.add` method](#animeventadd).  \nYou can remove a `wrappedListener` that was added by `addEventListener` method from the event by [`removeEventListener` method](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener). `AnimEvent.remove` method removes a listener from listeners that are controlled by AnimEvent.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanseki%2Fanim-event","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanseki%2Fanim-event","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanseki%2Fanim-event/lists"}