{"id":22356845,"url":"https://github.com/ayamflow/raf-scroll","last_synced_at":"2025-07-30T10:32:37.977Z","repository":{"id":29122708,"uuid":"32652457","full_name":"ayamflow/raf-scroll","owner":"ayamflow","description":"A scroll event that fires only once per frame.","archived":false,"fork":false,"pushed_at":"2017-12-22T09:18:02.000Z","size":13,"stargazers_count":38,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-27T22:44:43.564Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ayamflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-21T22:24:26.000Z","updated_at":"2024-09-06T22:34:25.000Z","dependencies_parsed_at":"2022-07-25T18:03:03.308Z","dependency_job_id":null,"html_url":"https://github.com/ayamflow/raf-scroll","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fraf-scroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fraf-scroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fraf-scroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fraf-scroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayamflow","download_url":"https://codeload.github.com/ayamflow/raf-scroll/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228124602,"owners_count":17873170,"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-12-04T14:12:11.781Z","updated_at":"2024-12-04T14:12:12.319Z","avatar_url":"https://github.com/ayamflow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"raf-scroll\n===\nA scroll event that fires only once per frame.\n\n## Installation\n\n`npm i raf-scroll --save`\n\n## Usage\n\nEvery event call is sync on a `requestAnimationFrame` (raf) loop.\nThe triggered event contains 2 properties, `scrollY` and `deltaY`.\n\n`rafScroll.init()`\nSetup the singleton (allows to teardown/recreate at will). Needs to be called before using the lib.\n\n`rafScroll.add(callback)`\nWill call `callback` maximum once per frame, if the scroll value has changed.\nAn `event` will be passed containing the current `scrollY` as well as the  `deltaY`.\n\n`rafScroll.addOnce(callback)`\nSame than `add` but only trigger the event once, then automatically unbinds itself. Useful for triggering behavior when user scrolls.\n\n`rafScroll.remove(callback)`\nUnbind the listener. Passing no `callback` will unbind all previous callbacks.\n\n`rafScroll.getCurrent()`\nManually get the `event` (containing last `scrollY`/`deltaY`). Note that you need to wait at least 1 frame to have valid values since the scroll data is read in a requestAnimationFrame.\n\n`rafScroll.destroy()`\nClean the singleton. It will auto-restart if you call `rafScroll.init`.\n\n## Example\n\n```js\n\nvar rafScroll = require('raf-scroll');\n\nrafScroll.add(function onScroll(event) {\n  if (window.innerHeight + event.scrollY \u003e= document.offsetHeight - window.innerHeight * 0.5) {\n    triggerInfiniteScroll();\n  }\n})\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayamflow%2Fraf-scroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayamflow%2Fraf-scroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayamflow%2Fraf-scroll/lists"}