{"id":13417954,"url":"https://github.com/pmndrs/use-gesture","last_synced_at":"2025-05-14T07:03:56.236Z","repository":{"id":37247965,"uuid":"126505563","full_name":"pmndrs/use-gesture","owner":"pmndrs","description":"👇Bread n butter utility for component-tied mouse/touch gestures in React and Vanilla Javascript.","archived":false,"fork":false,"pushed_at":"2024-07-15T14:21:52.000Z","size":186993,"stargazers_count":9319,"open_issues_count":44,"forks_count":315,"subscribers_count":42,"default_branch":"main","last_synced_at":"2025-04-30T13:32:35.866Z","etag":null,"topics":["drag","gestures","hooks","pinch","react","scroll","wheel","zoom"],"latest_commit_sha":null,"homepage":"https://use-gesture.netlify.app","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/pmndrs.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":"2018-03-23T15:37:58.000Z","updated_at":"2025-04-30T09:13:11.000Z","dependencies_parsed_at":"2023-11-22T16:03:11.113Z","dependency_job_id":"c4571897-e982-40e9-a3ed-c0f1ec93dee3","html_url":"https://github.com/pmndrs/use-gesture","commit_stats":{"total_commits":1271,"total_committers":64,"mean_commits":19.859375,"dds":"0.26671911880409127","last_synced_commit":"c779631aa05959638dee81b9a25fb1299a7467f6"},"previous_names":["pmndrs/react-use-gesture","drcmda/react-with-gesture","react-spring/react-use-gesture"],"tags_count":162,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmndrs%2Fuse-gesture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmndrs%2Fuse-gesture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmndrs%2Fuse-gesture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pmndrs%2Fuse-gesture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pmndrs","download_url":"https://codeload.github.com/pmndrs/use-gesture/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251864141,"owners_count":21656289,"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":["drag","gestures","hooks","pinch","react","scroll","wheel","zoom"],"created_at":"2024-07-30T22:00:56.093Z","updated_at":"2025-05-06T16:19:48.526Z","avatar_url":"https://github.com/pmndrs.png","language":"TypeScript","funding_links":[],"categories":["Uncategorized","TypeScript","UI Gestures \u0026 Tools","Libraries","React"],"sub_categories":["Uncategorized","JavaScript","Hook"],"readme":"# @use-gesture\n\n[![npm (tag)](https://img.shields.io/npm/v/@use-gesture/react?style=flat\u0026colorA=000000\u0026colorB=000000)](https://www.npmjs.com/package/@use-gesture/react) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@use-gesture/react?style=flat\u0026colorA=000000\u0026colorB=000000) ![NPM](https://img.shields.io/npm/l/@use-gesture/react?style=flat\u0026colorA=000000\u0026colorB=000000) [![Discord Shield](https://img.shields.io/discord/740090768164651008?style=flat\u0026colorA=000000\u0026colorB=000000\u0026label=discord\u0026logo=discord\u0026logoColor=ffffff)](https://discord.gg/poimandres)\n\n@use-gesture is a library that lets you bind richer mouse and touch events to any component or view. With the data you receive, it becomes trivial to set up gestures, and often takes no more than a few lines of code.\n\nYou can use it stand-alone, but to make the most of it you should combine it with an animation library like [react-spring](https://github.com/pmndrs/react-spring), though you can most certainly use any other.\n\n\u003cp align=\"middle\"\u003e\n  \u003ca href=\"https://codesandbox.io/s/github/pmndrs/use-gesture/tree/main/demo/src/sandboxes/draggable-list\"\u003e\u003cimg src=\"https://i.imgur.com/qLKJod3.gif\" width=\"400\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://codesandbox.io/s/github/pmndrs/use-gesture/tree/main/demo/src/sandboxes/cards-stack\"\u003e\u003cimg src=\"https://i.imgur.com/H6nXQEq.gif\" width=\"400\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://codesandbox.io/s/github/pmndrs/use-gesture/tree/main/demo/src/sandboxes/action-sheet\"\u003e\u003cimg src=\"https://i.imgur.com/THKPrmR.gif\" width=\"400\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://codesandbox.io/s/github/pmndrs/use-gesture/tree/main/demo/src/sandboxes/infinite-slideshow\"\u003e\u003cimg src=\"https://i.imgur.com/cuOfqST.gif\" width=\"400\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://codesandbox.io/s/github/pmndrs/use-gesture/tree/main/demo/src/sandboxes/viewpager\"\u003e\u003cimg src=\"https://i.imgur.com/iwZOfT9.gif\" width=\"400\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://codesandbox.io/s/github/pmndrs/use-gesture/tree/main/demo/src/sandboxes/card-zoom\"\u003e\u003cimg src=\"https://i.imgur.com/Walt1Ip.gif\" width=\"400\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"middle\"\u003e\u003ci\u003eThe demos are real click them!\u003c/i\u003e\u003c/p\u003e\n\n## Installation\n\n### React\n\n```bash\n#Yarn\nyarn add @use-gesture/react\n\n#NPM\nnpm install @use-gesture/react\n```\n\n### Vanilla javascript\n\n```bash\n#Yarn\nyarn add @use-gesture/vanilla\n\n#NPM\nnpm install @use-gesture/vanilla\n```\n\n### [Full documentation website](https://use-gesture.netlify.com)\n\n- [Available Gestures](https://use-gesture.netlify.com/docs/gestures)\n- [Gesture State](https://use-gesture.netlify.com/docs/state)\n- [Gesture Options](https://use-gesture.netlify.com/docs/options)\n- [FAQ](https://use-gesture.netlify.com/docs/faq)\n\n### Simple example\n\n\u003cp align=\"middle\"\u003e\n  \u003ca href=\"https://codesandbox.io/s/github/pmndrs/use-gesture/tree/main/demo/src/sandboxes/gesture-simplest\"\u003e\u003cimg src=\"https://i.imgur.com/AMzsEi3.gif\" width=\"400\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eReact\u003c/summary\u003e\n\n```jsx\nimport { useSpring, animated } from '@react-spring/web'\nimport { useDrag } from '@use-gesture/react'\n\nfunction Example() {\n  const [{ x, y }, api] = useSpring(() =\u003e ({ x: 0, y: 0 }))\n\n  // Set the drag hook and define component movement based on gesture data.\n  const bind = useDrag(({ down, movement: [mx, my] }) =\u003e {\n    api.start({ x: down ? mx : 0, y: down ? my : 0 })\n  })\n\n  // Bind it to a component.\n  return \u003canimated.div {...bind()} style={{ x, y, touchAction: 'none' }} /\u003e\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eVanilla javascript\u003c/summary\u003e\n\n```html\n\u003c!-- index.html --\u003e\n\u003cdiv id=\"drag\" /\u003e\n```\n\n```js\n// script.js\nconst el = document.getElementById('drag')\nconst gesture = new DragGesture(el, ({ active, movement: [mx, my] }) =\u003e {\n  setActive(active)\n  anime({\n    targets: el,\n    translateX: active ? mx : 0,\n    translateY: active ? my : 0,\n    duration: active ? 0 : 1000\n  })\n})\n\n// when you want to remove the listener\ngesture.destroy()\n```\n\n\u003c/details\u003e\n\nThe example above makes a `div` draggable so that it follows your mouse on drag, and returns to its initial position on release.\n\n**Make sure you always set [`touchAction`](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) on a draggable element to prevent glitches with the browser native scrolling on touch devices**.\n\n### Available hooks\n\n@use-gesture/react exports several hooks that can handle different gestures:\n\n| Hook         | Description                                |\n| ------------ | ------------------------------------------ |\n| `useDrag`    | Handles the drag gesture                   |\n| `useMove`    | Handles mouse move events                  |\n| `useHover`   | Handles mouse enter and mouse leave events |\n| `useScroll`  | Handles scroll events                      |\n| `useWheel`   | Handles wheel events                       |\n| `usePinch`   | Handles the pinch gesture                  |\n| `useGesture` | Handles multiple gestures in one hook      |\n\n#### [More on the full documentation website...](https://use-gesture.netlify.app/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmndrs%2Fuse-gesture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpmndrs%2Fuse-gesture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpmndrs%2Fuse-gesture/lists"}