{"id":21009107,"url":"https://github.com/avin/card-changer","last_synced_at":"2026-04-13T07:07:49.686Z","repository":{"id":44262358,"uuid":"249200383","full_name":"avin/card-changer","owner":"avin","description":"Cards stack UI lib","archived":false,"fork":false,"pushed_at":"2023-05-09T03:23:26.000Z","size":689,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T11:09:25.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://avin.github.io/card-changer","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/avin.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":"2020-03-22T14:26:23.000Z","updated_at":"2022-02-12T17:27:46.000Z","dependencies_parsed_at":"2022-09-10T00:12:32.560Z","dependency_job_id":null,"html_url":"https://github.com/avin/card-changer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Fcard-changer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Fcard-changer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Fcard-changer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avin%2Fcard-changer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avin","download_url":"https://codeload.github.com/avin/card-changer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243430687,"owners_count":20289762,"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-11-19T09:15:28.497Z","updated_at":"2025-12-30T10:24:39.693Z","avatar_url":"https://github.com/avin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Card-changer\n\nCards stack UI lib. No dependencies.\n\nCheck out [a live demo](https://avin.github.io/card-changer)\n\n[![Preview](./additional/preview.png)](https://avin.github.io/card-changer)\n\n## Usage\n\nInstall lib:\n\n```sh\nnpm install card-changer\n```\n\nMake root container for card-changer:\n\n```html\n\u003cdiv id=\"root\"\u003e\u003c/div\u003e\n```\n\nInit card-changer:\n\n```js\nimport CardChanger from \"card-changer\";\n\nconst cardChanger = new CardChanger(document.querySelector(\"#root\"), {\n  cards: [\n    {\n      id: \"card1\",\n      frontContent: \"...\", // HTML string or element with front card content\n      backContent: \"...\", // HTML string or element with back card content\n    },\n    {\n      id: \"card2\",\n      frontContent: \"...\",\n      backContent: \"...\",\n    },\n    // ...\n  ],\n  activeCardId: \"card1\",\n  stackSize: 3,\n  stackHeight: 40,\n});\n\n// Set active card\ncardChanger.activeCardId = \"card2\";\n\n// Rotate current card\ncardChanger.rotate();\n\n// Add handler on active card change\ncardChanger.on(\"change\", (activeCardId) =\u003e {\n  console.log(`Active card id is \"${activeCardId}\"`);\n});\n```\n\n## API\n\n### Options\n\n#### Option fields\n\n| Field            | Type      | Description                                                                        |\n| ---------------- | --------- | ---------------------------------------------------------------------------------- |\n| stackSize        | `Number`  | Amount of visible cards in stack                                                   |\n| stackHeight      | `Number`  | Height of back cards area                                                          |\n| rootClassName    | `String`  | Root class name for all generated sub-elements                                     |\n| dotsNavigation   | `Boolean` | Show dots navigation                                                               |\n| keepChangeOrder  | `Boolean` | Cards change sequentially with animations for each                                 |\n| animationSpeed   | `Number`  | Animation speed for change one card (should be the same as CSS animation duration) |\n| cards            | `Array`   | Array with cards object (see [Card fields](#card-fields))                          |\n| activeCardId     | `String`  | Card id that should be on top of the stack                                         |\n| unRotateOnChange | `Boolean` | Rotate to front card when it becomes inactive                                      |\n\n#### Card fields\n\n| Field        | Type                      | Description                                  |\n| ------------ | ------------------------- | -------------------------------------------- |\n| id           | `String`                  | card unique ID string                        |\n| frontContent | `String` or `HTMLElement` | HTML content with the front side of the card |\n| backContent  | `String` or `HTMLElement` | HTML content with the back side of the card  |\n\n### Methods\n\n- `rotate()` - rotate active card\n- `on(event, handler)` - add handler for card-changer event\n- `off(event, handler)` - remove handler for card-changer event\n\nTo set an active card id - assign it to `activeCardId` field:\n\n```js\ncardChanger.activeCardId = \"new_id\";\n```\n\n### Events\n\n| Field  | Params       | Description                 |\n| ------ | ------------ | --------------------------- |\n| change | activeCardId | fires on active card change |\n\n## Examples\n\nCheck out an example code [here](./demo/src/main.js)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favin%2Fcard-changer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favin%2Fcard-changer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favin%2Fcard-changer/lists"}