{"id":26266126,"url":"https://github.com/calvin-ll/delay-by-animation-frame","last_synced_at":"2025-03-14T03:16:56.353Z","repository":{"id":37088774,"uuid":"320685969","full_name":"Calvin-LL/delay-by-animation-frame","owner":"Calvin-LL","description":"A Promise wrapper around requestAnimationFrame","archived":false,"fork":false,"pushed_at":"2023-01-25T13:03:13.000Z","size":772,"stargazers_count":1,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-02-25T21:46:22.374Z","etag":null,"topics":["delay","promise","requestanimationframe"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/Calvin-LL.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-12-11T21:17:32.000Z","updated_at":"2021-08-16T21:52:29.000Z","dependencies_parsed_at":"2023-02-14T07:45:15.532Z","dependency_job_id":null,"html_url":"https://github.com/Calvin-LL/delay-by-animation-frame","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Calvin-LL%2Fdelay-by-animation-frame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Calvin-LL%2Fdelay-by-animation-frame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Calvin-LL%2Fdelay-by-animation-frame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Calvin-LL%2Fdelay-by-animation-frame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Calvin-LL","download_url":"https://codeload.github.com/Calvin-LL/delay-by-animation-frame/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243515532,"owners_count":20303258,"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":["delay","promise","requestanimationframe"],"created_at":"2025-03-14T03:16:55.762Z","updated_at":"2025-03-14T03:16:56.340Z","avatar_url":"https://github.com/Calvin-LL.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# delay-by-animation-frame\n\n[![npm](https://img.shields.io/npm/v/delay-by-animation-frame?style=flat)](https://www.npmjs.com/package/delay-by-animation-frame) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?style=flat)](https://opensource.org/licenses/MIT)\n\nThis library exports `() =\u003e new Promise((resolve) =\u003e requestAnimationFrame(resolve))`\n\nResolves to a [`DOMHighResTimeStamp`](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) which is a `double`\n\n## Install\n\nInstall with npm:\n\n```bash\nnpm install delay-by-animation-frame\n```\n\nInstall with yarn:\n\n```bash\nyarn add delay-by-animation-frame\n```\n\n## Example\n\n```javascript\nimport delayByAnimationFrame from \"delay-by-animation-frame\";\n\nasync function animate() {\n  const element = document.getElementById(\"element-id\");\n  let start;\n\n  while (true) {\n    const timestamp = await delayByAnimationFrame();\n\n    if (start === undefined) start = timestamp;\n\n    const elapsed = timestamp - start;\n\n    if (elapsed \u003e 2000) break;\n\n    element.style.transform =\n      \"translateX(\" + Math.min(0.1 * elapsed, 200) + \"px)\";\n  }\n}\n\nanimate();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalvin-ll%2Fdelay-by-animation-frame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalvin-ll%2Fdelay-by-animation-frame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalvin-ll%2Fdelay-by-animation-frame/lists"}