{"id":14961177,"url":"https://github.com/matthiaaas/framer-motion-hooks","last_synced_at":"2025-09-30T13:32:06.019Z","repository":{"id":41873232,"uuid":"354812067","full_name":"matthiaaas/framer-motion-hooks","owner":"matthiaaas","description":"Fill the hook gap in Framer Motion","archived":true,"fork":false,"pushed_at":"2022-11-11T02:57:43.000Z","size":71,"stargazers_count":163,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-16T10:40:56.105Z","etag":null,"topics":["framer-motion","hooks","in-view","react","scroll-progress","typescript","viewport"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/framer-motion-hooks","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/matthiaaas.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":"2021-04-05T11:29:18.000Z","updated_at":"2024-09-18T20:53:30.000Z","dependencies_parsed_at":"2022-08-11T19:50:59.651Z","dependency_job_id":null,"html_url":"https://github.com/matthiaaas/framer-motion-hooks","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/matthiaaas%2Fframer-motion-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthiaaas%2Fframer-motion-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthiaaas%2Fframer-motion-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matthiaaas%2Fframer-motion-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matthiaaas","download_url":"https://codeload.github.com/matthiaaas/framer-motion-hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234744628,"owners_count":18879955,"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":["framer-motion","hooks","in-view","react","scroll-progress","typescript","viewport"],"created_at":"2024-09-24T13:24:05.871Z","updated_at":"2025-09-30T13:32:00.730Z","avatar_url":"https://github.com/matthiaaas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Framer Motion Hooks\n\nFill the hook gap in Framer Motion.\n\n## Installation\n\n```bash\nnpm install framer-motion-hooks\n```\n\n**Note:** If you prefer `yarn` instead of `npm`, just use `yarn add framer-motion-hooks`.\n\n## Hooks\n\n### [`useInViewScroll`](docs/useInViewScroll.md)\n\nReturns a `MotionValue` representing the y scroll progress that updates when the target element is visible in viewport.\n\n```jsx\nconst MyComponent = () =\u003e {\n  const ref = useRef()\n\n  const progress = useInViewScroll(ref)\n\n  return \u003cmotion.div ref={ref} style={{ scale: progress }} /\u003e\n}\n```\n\n[Comprehensive example →](docs/useInViewScroll.md)\n\n#### API\n\n`const scrollProgress = useInViewScroll(ref, options)`\n\n- `scrollProgress`: A number between 0 and 1 indicating relative page scroll\n- `ref`: React ref target element\n- `options`: _(optional)_ Scroll options (e.g. threshold)\n\n### [`useInViewAnimate`](docs/useInViewAnimate.md) *Deprecated*\n\n**Note:** Deprecated in favor of Framer Motion's native [`whileInView`](https://www.framer.com/docs/gestures/#viewport) prop introduced in version 5.3.\n\nFires an animation as soon as the element is visible in viewport.\n\n```jsx\nconst MyComponent = () =\u003e {\n  const { inViewRef, animation } = useInViewAnimate({ animate: \"visible\" })\n\n  return (\n    \u003cmotion.div\n      ref={inViewRef}\n      initial=\"initial\"\n      animate={animation}\n      variants={variants}\n    /\u003e\n  )\n}\n\nconst variants = {\n  initial: {\n    x: 0\n  },\n  visible: {\n    x: 200\n  }\n}\n```\n\n[Comprehensive example →](docs/useInViewAnimate.md)\n\n**Note**: Also works with direct props on the React element\n\n#### API\n\n`const { inViewRef, animation } = useInViewAnimate(variants, options)`\n\n- `inViewRef`: React ref\n- `animation`: Motion animation controls\n- `variants`: Motion target object\n- `options`: _(optional)_ Intersection options\n\n### [`useMotionAsState`](docs/useMotionAsState.md)\n\nReturns a React state value that updates when the MotionValue changes\n\n```jsx\nconst MyComponent = () =\u003e {\n  const { scrollY } = useViewportScroll()\n\n  const reactState = useMotionAsState(scrollY)\n\n  return \u003cspan\u003e{reactState}\u003c/span\u003e\n}\n```\n\n#### API\n\n`const state = useMotionAsState(value)`\n\n- `state`: React state\n- `value`: Motion value\n\n### [`useStateAsMotion`](docs/useStateAsMotion.md)\n\nReturns a MotionValue value that updates when the React state changes\n\n```jsx\nconst MyComponent = () =\u003e {\n  const [opacity, setOpacity] = useState(0)\n\n  const motionOpacity = useStateAsMotion(opacity)\n\n  return \u003cmotion.div style={{ opacity: motionOpacity }} /\u003e\n}\n```\n\n#### API\n\n`const value = useStateAsMotion(state)`\n\n- `value`: Motion value\n- `state`: React state\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthiaaas%2Fframer-motion-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthiaaas%2Fframer-motion-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthiaaas%2Fframer-motion-hooks/lists"}