{"id":25421424,"url":"https://github.com/lachlanarthur/scroll-snap-api","last_synced_at":"2025-10-31T12:30:24.214Z","repository":{"id":42884544,"uuid":"255488202","full_name":"LachlanArthur/scroll-snap-api","owner":"LachlanArthur","description":"JavaScript API for interacting with CSS scroll-snap","archived":false,"fork":false,"pushed_at":"2023-01-06T03:22:16.000Z","size":675,"stargazers_count":12,"open_issues_count":9,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T06:43:05.757Z","etag":null,"topics":["css-scroll-snap"],"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/LachlanArthur.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":"2020-04-14T02:13:26.000Z","updated_at":"2024-07-30T13:05:58.000Z","dependencies_parsed_at":"2023-02-05T05:00:39.870Z","dependency_job_id":null,"html_url":"https://github.com/LachlanArthur/scroll-snap-api","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LachlanArthur%2Fscroll-snap-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LachlanArthur%2Fscroll-snap-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LachlanArthur%2Fscroll-snap-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LachlanArthur%2Fscroll-snap-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LachlanArthur","download_url":"https://codeload.github.com/LachlanArthur/scroll-snap-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239195487,"owners_count":19598036,"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":["css-scroll-snap"],"created_at":"2025-02-16T20:39:26.281Z","updated_at":"2025-10-31T12:30:24.171Z","avatar_url":"https://github.com/LachlanArthur.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scroll-snap-api\n\nJavaScript API for interacting with [CSS scroll-snap](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Scroll_Snap).\n\nZero dependencies.\n\nAutomatically accounts for `scroll-padding`.\n\n## Install\n\n```shell\nyarn add scroll-snap-api\n\nnpm install --save scroll-snap-api\n```\n\nOr use directly\n\n```js\nimport * as scrollSnapApi from 'https://cdn.pika.dev/scroll-snap-api';\n```\n\n## Usage\n\n### Scroll an element to the next snap position in a direction\n\n```js\nimport { scrollSnapToNext } from 'scroll-snap-api';\n\nscrollSnapToNext( scrollingElement, 'right' ); // 'left', 'right', 'up', 'down'\n```\n\n### Get the possible scroll positions\n\n```js\nimport { getScrollSnapPositions } from 'scroll-snap-api';\n\nconst scroll = getScrollSnapPositions( scrollingElement );\n\n/*\n{\n  x: [ 0, 100, 150, 200 ],\n  y: [ 0, 200, 400, 600, 800 ],\n}\n*/\n```\n\n### Get the raw snap positions\n\nNote: these are not scroll positions.\n\n```js\nimport { getSnapPositions } from 'scroll-snap-api';\n\nconst snap = getSnapPositions( scrollingElement );\n\n/*\n{\n  x: {\n    start: [ 0, 100 ],\n    center: [ 300 ],\n    end: [ 500 ],\n  },\n  y: {\n    start: [ 0 ],\n    center: [ 250, 500, 750 ],\n    end: [ 1000 ],\n  },\n}\n*/\n```\n\n![Diagram showing difference between function calls](.github/explain.png)\n\n## TODO\n\n- More documentation\n- Support `dir=\"rtl\"`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flachlanarthur%2Fscroll-snap-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flachlanarthur%2Fscroll-snap-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flachlanarthur%2Fscroll-snap-api/lists"}