{"id":13606874,"url":"https://github.com/arthurdenner/use-lax","last_synced_at":"2025-04-12T11:30:59.405Z","repository":{"id":34345360,"uuid":"177500514","full_name":"arthurdenner/use-lax","owner":"arthurdenner","description":"React hook to use with lax.js","archived":true,"fork":false,"pushed_at":"2023-07-19T00:54:56.000Z","size":3699,"stargazers_count":62,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T21:34:47.510Z","etag":null,"topics":["animation","hacktoberfest","lax","react"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/arthurdenner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"arthurdenner","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.buymeacoffee.com/arthurdenner"]}},"created_at":"2019-03-25T02:30:58.000Z","updated_at":"2024-04-16T07:58:43.000Z","dependencies_parsed_at":"2024-01-19T10:12:52.546Z","dependency_job_id":"7a8b2e55-220d-4527-b3db-0c14fea9c756","html_url":"https://github.com/arthurdenner/use-lax","commit_stats":{"total_commits":756,"total_committers":6,"mean_commits":126.0,"dds":0.6031746031746033,"last_synced_commit":"34b6f345c05db13346b468d1f33672ac70cf1a6d"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurdenner%2Fuse-lax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurdenner%2Fuse-lax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurdenner%2Fuse-lax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurdenner%2Fuse-lax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arthurdenner","download_url":"https://codeload.github.com/arthurdenner/use-lax/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248560055,"owners_count":21124585,"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","hacktoberfest","lax","react"],"created_at":"2024-08-01T19:01:13.292Z","updated_at":"2025-04-12T11:30:59.030Z","avatar_url":"https://github.com/arthurdenner.png","language":"TypeScript","funding_links":["https://github.com/sponsors/arthurdenner","https://www.buymeacoffee.com/arthurdenner"],"categories":["TypeScript"],"sub_categories":[],"readme":"# use-lax\n\n[![npm](https://img.shields.io/npm/v/use-lax.svg)](https://www.npmjs.org/package/use-lax)\n[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg)](#contributors)\n\nReact hook to use with [lax.js](https://github.com/alexfoxy/lax.js).\n\n## Usage\n\n```javascript\nimport React from 'react';\nimport { useLax, useLaxElement } from 'use-lax';\n\nfunction App() {\n  const [showBubble, setBubble] = useState(false);\n  const toggleBubble = () =\u003e setBubble(!showBubble);\n\n  // Use once in the top level element\n  // to configure drivers and initial elements\n  // https://github.com/alexfoxy/lax.js#setup\n  useLax({\n    drivers: [\n      {\n        name: 'scrollY',\n        getValueFn: () =\u003e window.scrollY,\n      },\n    ],\n  });\n\n  return (\n    \u003cdiv\u003e\n      \u003cbutton className=\"toggle-bubble\" onClick={toggleBubble}\u003e\n        Toggle Bubble\n      \u003c/button\u003e\n      \u003cp\u003e{showBubble ? '...now scroll down...' : '^ press the button ^'}\u003c/p\u003e\n      {showBubble ? \u003cBubble /\u003e : null}\n    \u003c/div\u003e\n  );\n}\n\nfunction Bubble() {\n  // Use it on every component added dynamically\n  // and provide the animation driven from the drivers\n  const ref = useLaxElement({\n    animationData: {\n      scrollY: {\n        presets: ['fadeInOut:200:0'],\n        translateX: [\n          [0, 'screenHeight'],\n          [0, 'screenWidth'],\n        ],\n      },\n    },\n  });\n\n  return \u003cdiv ref={ref} className=\"bubble\" /\u003e;\n}\n```\n\n- [Full example above](https://codesandbox.io/s/q9882qjxzq)\n- [Lax homepage example](https://codesandbox.io/s/039krok5ml) - [HTML version](https://alexfox.dev/lax.js/)\n- [Mario example](https://codesandbox.io/s/r48kz0okrm) - [HTML version](https://codesandbox.io/s/vcv4k)\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/arthurdenner\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/13774309?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eArthur Denner\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/arthurdenner/use-lax/commits?author=arthurdenner\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#design-arthurdenner\" title=\"Design\"\u003e🎨\u003c/a\u003e \u003ca href=\"https://github.com/arthurdenner/use-lax/commits?author=arthurdenner\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#example-arthurdenner\" title=\"Examples\"\u003e💡\u003c/a\u003e \u003ca href=\"#ideas-arthurdenner\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"#maintenance-arthurdenner\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/Sirk\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/1640743?v=4\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAntoine Martin\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/arthurdenner/use-lax/commits?author=Sirk\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farthurdenner%2Fuse-lax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farthurdenner%2Fuse-lax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farthurdenner%2Fuse-lax/lists"}