{"id":22105225,"url":"https://github.com/zhangyu1818/use-flip","last_synced_at":"2026-05-05T15:33:31.525Z","repository":{"id":231347140,"uuid":"781550447","full_name":"zhangyu1818/use-flip","owner":"zhangyu1818","description":"Effortless FLIP animations with a React Hook for smoother transitions.","archived":false,"fork":false,"pushed_at":"2024-04-08T02:35:01.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T06:52:02.059Z","etag":null,"topics":["animation","flip","react","react-hooks"],"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/zhangyu1818.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-03T15:40:30.000Z","updated_at":"2024-04-03T15:43:21.000Z","dependencies_parsed_at":"2024-04-08T03:32:51.190Z","dependency_job_id":null,"html_url":"https://github.com/zhangyu1818/use-flip","commit_stats":null,"previous_names":["zhangyu1818/use-flip"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyu1818%2Fuse-flip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyu1818%2Fuse-flip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyu1818%2Fuse-flip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyu1818%2Fuse-flip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhangyu1818","download_url":"https://codeload.github.com/zhangyu1818/use-flip/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245200674,"owners_count":20576673,"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","flip","react","react-hooks"],"created_at":"2024-12-01T06:39:54.674Z","updated_at":"2026-05-05T15:33:26.480Z","avatar_url":"https://github.com/zhangyu1818.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-flip\n\nA zero-dependency React hook for executing FLIP (First, Last, Invert, Play) animations within your React applications. It offers a seamless and efficient method for animating changes in the positions and dimensions of elements.\n\n## Installation\n\n```bash\npnpm install use-flip\n```\n\n## Usage\n\nHere's a basic example to get you started:\n\n[![Edit use-flip](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/p/sandbox/use-flip-hpmjxz)\n\n```jsx\nimport React, { useState } from 'react'\nimport { useFlip } from 'use-flip'\n\nfunction ExpandableComponent() {\n  const [expanded, setExpanded] = useState(false)\n  const flipRef = useFlip([expanded], {\n    duration: 300,\n    easing: 'ease-in-out',\n    dimensions: 'height',\n  })\n\n  return (\n    \u003cdiv\u003e\n      \u003cbutton onClick={() =\u003e setExpanded(!expanded)}\u003e{expanded ? 'Collapse' : 'Expand'}\u003c/button\u003e\n      \u003cdiv ref={flipRef} style={{ overflow: 'hidden', background: '#f0f0f0' }}\u003e\n        {expanded \u0026\u0026 (\n          \u003cp style={{ margin: 20 }}\u003e\n            More content here. When expanding or collapsing, this content will animate smoothly, demonstrating the FLIP\n            animation.\n          \u003c/p\u003e\n        )}\n      \u003c/div\u003e\n    \u003c/div\u003e\n  )\n}\n```\n\n## API\n\n### `useFlip(deps, options)`\n\n#### Parameters\n\n- `deps: unknown[]` - An array of dependencies that will trigger the animation when changed.\n- `options: FlipOptions` - An optional configuration object for the animation.\n\n#### Options\n\n- `dimensions?: 'width' | 'height' | true` - Specifies whether to animate width and/or height. If set to `true`, both width and height are animated.\n- `duration?: number` - The duration of the animation, in milliseconds. The default is `300`.\n- `easing?: string` - The CSS easing function for the animation. The default is `'ease'`.\n- `fill?: FillMode` - The fill mode of the animation, determining the styling of the element before and after the animation. The default is `'auto'`.\n\n## Contributing\n\nContributions are always welcome!\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangyu1818%2Fuse-flip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhangyu1818%2Fuse-flip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangyu1818%2Fuse-flip/lists"}