{"id":20180363,"url":"https://github.com/brunnolou/runfor","last_synced_at":"2025-06-11T17:02:52.549Z","repository":{"id":73656636,"uuid":"103711824","full_name":"brunnolou/runFor","owner":"brunnolou","description":"Run a performant function for a period of time","archived":false,"fork":false,"pushed_at":"2017-09-16T11:37:06.000Z","size":66,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-19T15:12:36.959Z","etag":null,"topics":["animation","duration","raf","requestanimationframe"],"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/brunnolou.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,"zenodo":null}},"created_at":"2017-09-16T00:16:59.000Z","updated_at":"2025-02-11T15:49:40.000Z","dependencies_parsed_at":"2023-04-18T23:28:02.437Z","dependency_job_id":null,"html_url":"https://github.com/brunnolou/runFor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/brunnolou/runFor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunnolou%2FrunFor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunnolou%2FrunFor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunnolou%2FrunFor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunnolou%2FrunFor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brunnolou","download_url":"https://codeload.github.com/brunnolou/runFor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brunnolou%2FrunFor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259301676,"owners_count":22836975,"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","duration","raf","requestanimationframe"],"created_at":"2024-11-14T02:30:17.709Z","updated_at":"2025-06-11T17:02:52.545Z","avatar_url":"https://github.com/brunnolou.png","language":"JavaScript","readme":"# `runFor(fn, ms)`\n\n[![npm version](https://badge.fury.io/js/runfor.svg?v1)](https://badge.fury.io/js/runfor)\n![](https://img.shields.io/github/size/brunnolou/runfor/lib/index.min.js.svg)\n\n### Run a performant function for a period of time\nRun `requestAnimationFrame` for the specified duration.\n\n## Install\n`npm install --save runfor`\n\nor\n\n`yarn add runfor`\n\n## Usage\n```js\nrunFor(progressFn, msDuration);\n```\n\n## Example\n```js\nimport runFor from 'runfor';\n\nfunction moveX(progress) {\n\t// Move right 200px\n  div.style.transform = `translateX(${progress * 200}px`;\n}\n\n// Run moveX for 1sec with a progress between 0 and 1.\nrunFor(p =\u003e moveX(p), 1000);\n\n```\n\nCheck the `examples/` folder to see full examples.\n\n## API\n\nOptionally you can stop or start the animation with this functions:\n```js\nconst runner = runFor(fn, 1000);\n\nrunner.toggle()\nrunner.stop()\nrunner.start()\n```\n\n### `.stop()`\nStops the animation.\n### `.start()`\nStarts the animation keeping the previous progress.\n### `.toggle()`\nToggle start / stop.\n### `.restart()`\nRestart animation from the beginning\n\n\n## Development\n`yarn install`\n\n`yarn run dev`\n\n## Test\n`yarn test`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunnolou%2Frunfor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrunnolou%2Frunfor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrunnolou%2Frunfor/lists"}