{"id":23020579,"url":"https://github.com/dipeshrai123/react-ui-animate","last_synced_at":"2025-12-27T10:13:02.626Z","repository":{"id":37047614,"uuid":"325238862","full_name":"dipeshrai123/react-ui-animate","owner":"dipeshrai123","description":"Create smooth animations and interactive gestures in React applications effortlessly :computer:","archived":false,"fork":false,"pushed_at":"2024-09-29T17:24:44.000Z","size":1893,"stargazers_count":42,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"next","last_synced_at":"2025-03-26T07:07:04.275Z","etag":null,"topics":["animation","gesture","interaction"],"latest_commit_sha":null,"homepage":"https://react-ui-animate.js.org/","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/dipeshrai123.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}},"created_at":"2020-12-29T09:05:57.000Z","updated_at":"2024-09-29T17:23:45.000Z","dependencies_parsed_at":"2024-08-01T17:29:41.159Z","dependency_job_id":"e7fd345d-e824-46ff-aa8f-64a16c4ce6b9","html_url":"https://github.com/dipeshrai123/react-ui-animate","commit_stats":null,"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipeshrai123%2Freact-ui-animate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipeshrai123%2Freact-ui-animate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipeshrai123%2Freact-ui-animate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipeshrai123%2Freact-ui-animate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dipeshrai123","download_url":"https://codeload.github.com/dipeshrai123/react-ui-animate/tar.gz/refs/heads/next","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246811310,"owners_count":20837752,"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","gesture","interaction"],"created_at":"2024-12-15T12:14:28.006Z","updated_at":"2025-12-27T10:13:02.587Z","avatar_url":"https://github.com/dipeshrai123.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React UI Animate\n\n[![npm version](https://badge.fury.io/js/react-ui-animate.svg)](https://badge.fury.io/js/react-ui-animate)\n\n\u003e Create smooth animations and interactive gestures in React applications effortlessly.\n\n### Install\n\nYou can install react-ui-animate via `npm` or `yarn`:\n\n```sh\nnpm i react-ui-animate\n```\n\n```sh\nyarn add react-ui-animate\n```\n\n### Getting Started\n\nThe `react-ui-animate` library provides a straightforward way to add animations and gestures to your React components. Here’s how you can get started quickly:\n\n```javascript\nimport { animate, useValue } from 'react-ui-animate';\n\nexport default function () {\n  const opacity = useValue(0); // Initialize\n\n  return (\n    \u003c\u003e\n      \u003canimate.div\n        style={{\n          opacity: opacity.value, // Apply\n          width: 100,\n          padding: 20,\n          background: '#39F',\n        }}\n      \u003e\n        ANIMATED\n      \u003c/animate.div\u003e\n      \n      \u003cbutton \n        onClick={() =\u003e {\n          opacity.value = 1 // Update\n        }}\n      \u003e\n        Animate Me\n      \u003c/button\u003e\n    \u003c/\u003e\n  );\n}\n```\n\nIn this example, clicking the `Animate Me` button changes the opacity from 0 to 1.\n\n---\n\n### Implementation Steps\n\n#### 1. Initialize\n\nThe `useValue()` hook is central to creating animations. It initializes an animated value and allows you to seamlessly update it to create dynamic effects.\n\n```javascript\nconst opacity = useValue(0); // Initialize a animation value 0\n```\n\n#### 2. Apply\n\n`animate.div` is a special component designed to work with `useValue()`. It simplifies animating elements by directly using animated values.\n\n```jsx\nimport { useValue, animate } from 'react-ui-animate'\n\nconst width = useValue(100); // Start with a width of 100\n\n\u003canimate.div\n  style={{\n    width: width.value,\n    height: 100,\n    backgroundColor: '#39f',\n  }}\n/\u003e;\n```\n\n#### 3. Update\n\nTo update the value simply assign the initialized animated node with a value.\n\n```jsx\nimport { useValue, withSpring } from 'react-ui-animate';\n\nconst width = useValue(100);\n\n\u003cbutton \n  onClick={() =\u003e {\n      // Update\n      width.value = withSpring(400); \n  }}\n\u003e\n  Update\n\u003c/button\u003e\n```\n\nIn this example, `withSpring` runs spring animation when updating the value.\n\n---\n\n#### `interpolate`\n\nThe `interpolate()` function is useful for mapping values from one range to another, enabling more complex animations.\n\n```javascript\nimport { useValue, animate, interpolate } from 'react-ui-animate';\n\nconst width = useValue(100);\n\n\u003canimate.div\n  style={{\n    width: width.value,\n    height: 100,\n    backgroundColor: interpolate(width.value, [100, 200], ['red', 'blue']),\n  }}\n/\u003e;\n```\n\nIn this example, as the width changes from 100 to 200, the background color smoothly transitions from red to blue.\n\n#### Modifiers\n\nYou can dynamically modify animation configurations by assigning values to an animated value using various animation functions.\n\nTo apply a spring animation and update the value to `10`:\n\n```jsx\nx.value = withSpring(10);\n```\n\nTo apply a timing animation with a duration of 5000 milliseconds:\n\n```jsx\nx.value = withTiming(10, { duration: 5000 });\n```\n\nTo create sequential transitions using the `withSequence` function with dynamic modifiers like `withSpring` and `withTiming`:\n\n```jsx\nx.value = withSequence([withSpring(50), withTiming(100), withEase(200)]);\n```\n\n#### `useMount()`\n\nThe `useMount()` hook facilitates managing the mounting and unmounting of a component with animations.\n\n```jsx\nimport { useMount } from 'react-ui-animate';\n\nexport default function App() {\n  const [visible, setVisible] = useState(false);\n\n  const open = useMount(visible);\n\n  return open((animation, mounted) =\u003e mounted \u0026\u0026 \u003canimate.div /\u003e);\n}\n```\n\nIn this example,\n\n1. A state variable `visible` determines whether the component is visible.\n2. The `useMount` hook takes `visible` as an argument and provides animation states for mounting and unmounting.\n3. The `open` function, returned by `useMount`, is used to conditionally render `animate.div` based on the `mounted` boolean and apply the transition animation.\n\n---\n\n### Gestures\n\nThe `react-ui-animate` library also provides several hooks for handling different types of gestures:\n\n1. `useDrag`: Handles drag gestures on elements.\n2. `useMouseMove`: Handles mouse movements.\n3. `useScroll`: Handles scrolling of the document.\n4. `useWheel`: Handles wheel rotation gestures.\n5. `useGesture`: Handles combinations of various gestures.\n\n**Example**: `useDrag`\n\nHere’s an example of using the useDrag hook to enable drag gestures:\n\n```jsx\nimport { useValue, animate, useDrag, withSpring } from 'react-ui-animate';\n\nexport const Draggable = () =\u003e {\n  const translateX = useValue(0);\n\n  const bind = useDrag(function ({ down, movementX }) {\n    translateX.value = down ? movementX : withSpring(0);\n  });\n\n  return (\n    \u003canimate.div\n      {...bind()}\n      style={{\n        width: 100,\n        height: 100,\n        backgroundColor: '#3399ff',\n        translateX: translateX.value,\n      }}\n    /\u003e\n  );\n};\n```\n\nIn this example, the blue block can be dragged horizontally by clicking and dragging.\n\n## Documentation\n\nFor detailed documentation and examples, visit the official [react-ui-animate documentation](http://react-ui-animate.js.org/).\n\n## License\n\nThis library is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdipeshrai123%2Freact-ui-animate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdipeshrai123%2Freact-ui-animate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdipeshrai123%2Freact-ui-animate/lists"}