{"id":19988500,"url":"https://github.com/bespoyasov/scroller","last_synced_at":"2025-04-05T03:12:56.037Z","repository":{"id":29600781,"uuid":"33140876","full_name":"bespoyasov/scroller","owner":"bespoyasov","description":"Fast, light-weight (4KB gzip), and dependency-free content scroller.","archived":false,"fork":false,"pushed_at":"2025-01-25T14:10:44.000Z","size":3010,"stargazers_count":124,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T02:08:31.041Z","etag":null,"topics":["component","dependency-free","drag-and-drop","javascript","scroller","ui"],"latest_commit_sha":null,"homepage":"","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/bespoyasov.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["bespoyasov.me/support/","bespoyasov.ru/support/"]}},"created_at":"2015-03-30T18:38:24.000Z","updated_at":"2025-01-25T14:10:48.000Z","dependencies_parsed_at":"2023-02-19T12:00:23.344Z","dependency_job_id":"a982cb9a-6c72-4d64-b6a3-f8ca3dc92b5a","html_url":"https://github.com/bespoyasov/scroller","commit_stats":{"total_commits":451,"total_committers":4,"mean_commits":112.75,"dds":0.07982261640798227,"last_synced_commit":"ac8acb0a5b7dcf021ed041c40f6ca27b0f0905dc"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bespoyasov%2Fscroller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bespoyasov%2Fscroller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bespoyasov%2Fscroller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bespoyasov%2Fscroller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bespoyasov","download_url":"https://codeload.github.com/bespoyasov/scroller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"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":["component","dependency-free","drag-and-drop","javascript","scroller","ui"],"created_at":"2024-11-13T04:43:14.734Z","updated_at":"2025-04-05T03:12:56.016Z","avatar_url":"https://github.com/bespoyasov.png","language":"JavaScript","funding_links":["bespoyasov.me/support/","bespoyasov.ru/support/"],"categories":[],"sub_categories":[],"readme":"# Scroller\n\nFast, light-weight (4KB gzip), and dependency-free content scroller.\n\nhttps://user-images.githubusercontent.com/9102374/170833443-b9428466-a9fd-48e5-b18b-4c4089137dd5.mp4\n\nFor more examples of how it works with different settings and UI conditions, check out [this link](https://bespoyasov.ru/scroller/example/).\n\n## Installation\n\nInstall Scroller with npm:\n\n```shell\nnpm install prokrutchik\n```\n\nAdd the scripts and styles to your project:\n\n```js\nimport { Scroller } from \"prokrutchik\";\nimport \"prokrutchik/styles.css\";\n```\n\nOr add them directly to the HTML file:\n\n```html\n\u003cscript src=\"/path/to/prokrutchik/browser.js\"\u003e\u003c/script\u003e\n\u003clink href=\"/path/to/prokrutchik/styles.css\" rel=\"stylesheet\" /\u003e\n```\n\n## Initialization\n\nBy default, Scroller provides auto initialization for all the `.scroller` elements on the page:\n\n```html\n\u003cul class=\"scroller\"\u003e\n  \u003cli\u003eFirst item\u003c/li\u003e\n  \u003cli\u003eSecond item\u003c/li\u003e\n  \u003cli\u003eThird item\u003c/li\u003e\n\u003c/ul\u003e\n```\n\nYou can also initialize the instance manually:\n\n```html\n\u003cul class=\"foo\"\u003e\n  \u003cli\u003eFirst item\u003c/li\u003e\n  \u003cli\u003eSecond item\u003c/li\u003e\n  \u003cli\u003eThird item\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003cscript type=\"module\"\u003e\n  import { Scroller } from \"prokrutchik\";\n\n  const instance = new Scroller({\n    element: document.querySelector(\".foo\"),\n  });\n\u003c/script\u003e\n```\n\n## Configuration\n\nYou can configure Scroller via `data-` attributes in HTML:\n\n- `data-navigation`, shows/hides the navigation buttons, `\"visible\" | \"hidden\"`;\n- `data-scrollbar`, shows/hides the scrollbar under the content, `\"visible\" | \"hidden\"`;\n- `data-align`, specifies how to align the content if it fits the screen, `\"start\" | \"center\" | \"end\"`;\n- `data-start-position`, initial position of the content, `number of px | \"start\" | \"center\" | \"end\"`;\n- `data-start-duration`, starting animation duration, `number of milliseconds`.\n\nScroller items can be configured with:\n\n- `data-anchor`, label of the item in the navigation, `string`;\n- `data-focused`, if defined, Scroller will scroll to this item at the start.\n\n### Using JavaScript\n\nYou can also configure Scroller using the config object:\n\n```js\nconst scroller = new Scroller({\n  element: document.querySelector(\".foo\"),\n\n  // Show/hide the scrollbar, \"visible\" | \"hidden\":\n  scrollbar: \"hidden\",\n\n  // Show/hide the navigation, \"visible\" | \"hidden\":\n  navigation: \"hidden\",\n\n  // How to align content if it fits the screen, \"start\" | \"center\" | \"end\":\n  align: \"center\",\n\n  // Initial scroller content position, \"start\" | \"center\" | \"end\" | number of px:\n  startPosition: \"center\",\n\n  // Starting animation duration, number of milliseconds:\n  startDuration: 500,\n});\n```\n\n## Public API\n\nScroller provides API for changing current position, handling item clicks, and dynamically updating the config.\n\n### Position Change\n\nFor position change, use the `scrollTo` method:\n\n```js\n// Scrolls to the beginning of the content\nscroller.scrollTo(\"start\");\n\n// Scrolls to the center of the content:\nscroller.scrollTo(\"center\");\n\n// Scrolls to the end of the content:\nscroller.scrollTo(\"end\");\n\n// Scrolls to 100px from the start of the content:\nscroller.scrollTo(100);\n\n// Second optional parameter specifies\n// the animation duration in milliseconds.\n// Scrolls to center in 500 ms:\nscroller.scrollTo(\"center\", 500);\n```\n\n### Item Click Callback\n\nFor handling clicks on items, specify the `onItemClick` handler in the config:\n\n```js\nconst scroller = new Scroller({\n  element: document.querySelector(\".foo\"),\n  onItemClick: (event) =\u003e {\n    /* The `event` argument here is `TouchEvent` or `MouseEvent` depending on the user device. */\n  },\n});\n```\n\n### Config Updates\n\nFor configuration updates, use the `update` method:\n\n```js\nscroller.update({\n  scrollbar: \"hidden\",\n  navigation: \"hidden\",\n  align: \"center\",\n  onItemClick: someFunc,\n});\n```\n\n## Examples\n\nScroller with disabled scrollbar, active navigation, and start alignment, configured via HTML data-attributes:\n\n```html\n\u003chead\u003e\n  \u003clink href=\"/path/to/prokrutchik/styles.css\" rel=\"stylesheet\" /\u003e\n  \u003cscript src=\"/path/to/prokrutchik/browser.js\" defer\u003e\u003c/script\u003e\n\u003c/head\u003e\n\n\u003cbody\u003e\n  \u003cul class=\"scroller\" data-scrollbar=\"hidden\" data-align=\"start\"\u003e\n    \u003cimg src=\"example.png\" data-anchor=\"anchor1\" /\u003e\n    \u003cdiv data-anchor=\"anchor2\"\u003e\u003c/div\u003e\n    \u003ctable data-anchor=\"anchor3\"\u003e\u003c/table\u003e\n    \u003c!-- ... --\u003e\n  \u003c/div\u003e\n\u003c/body\u003e\n```\n\nScroller with the same settings configured via config object:\n\n```js\nimport { Scroller } from \"prokrutchik\";\nimport \"prokrutchik/styles.css\";\n\nconst myScroller = new Scroller({\n  el: document.querySelector(\".foo\"),\n  scrollbar: \"hidden\",\n  align: \"start\",\n});\n```\n\n## Components\n\nIf you want to use Scroller with React or Vue, check out these packages:\n\n- [React Scroller](https://github.com/bespoyasov/react-scroller)\n- [Vue Scroller](https://github.com/bespoyasov/vue-scroller)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbespoyasov%2Fscroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbespoyasov%2Fscroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbespoyasov%2Fscroller/lists"}