{"id":16907898,"url":"https://github.com/timc1/react-drag-elements","last_synced_at":"2025-03-22T10:31:23.037Z","repository":{"id":65483353,"uuid":"173378950","full_name":"timc1/react-drag-elements","owner":"timc1","description":"A small \u0026 efficient React Hook that allows users to drag items around and update lists of elements.","archived":false,"fork":false,"pushed_at":"2019-08-25T06:51:50.000Z","size":593,"stargazers_count":29,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T10:21:38.025Z","etag":null,"topics":["animation","css","html","javascript","react","typescript"],"latest_commit_sha":null,"homepage":null,"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/timc1.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":"2019-03-01T22:59:14.000Z","updated_at":"2025-03-06T07:47:26.000Z","dependencies_parsed_at":"2023-01-25T11:15:30.950Z","dependency_job_id":null,"html_url":"https://github.com/timc1/react-drag-elements","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timc1%2Freact-drag-elements","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timc1%2Freact-drag-elements/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timc1%2Freact-drag-elements/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timc1%2Freact-drag-elements/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timc1","download_url":"https://codeload.github.com/timc1/react-drag-elements/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244943788,"owners_count":20536290,"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","css","html","javascript","react","typescript"],"created_at":"2024-10-13T18:49:15.664Z","updated_at":"2025-03-22T10:31:22.689Z","avatar_url":"https://github.com/timc1.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  react-drag-elements\n  \u003cbr\u003e\n  \u003cbr\u003e\n  📱🕹\n\u003c/h1\u003e\n\u003cp align=\"center\" style=\"font-size: 1.5rem;\"\u003e\n  A light weight and efficient Hook that make DOM elements draggable \u0026 reorganizable.\n\u003c/p\u003e\n\n## About\n\nThis project is inspired by the MacOS Launchpad iOS Springboard UI, where items can be dragged\naround and reordered.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"demo.gif\" alt=\"demo\" /\u003e\n\u003c/p\u003e\n\n## Setup\n\n```\nyarn add react-drag-elements\n```\n\nor\n\n```\nnpm install react-drag-elements\n```\n\n## Usage\n\n```\nimport useDragElements from 'react-drag-elements'\n\nconst initialItems = [\n  { id: 0, text: 'One', color: '#616AFF' },\n  { id: 1, text: 'Two', color: '#2DBAE7' },\n  { id: 2, text: 'Three', color: '#fd4e4e' },\n]\n\nexport default function App() {\n\n  const { items, getItemProps } = useDragElements({\n    initialItems,\n    delay: 200, // optional\n    debounceMs: 200, // optional\n    easeFunction: `ease-out` // optional\n  })\n\n  return (\n    \u003cul\u003e\n      {items.map((item: any) =\u003e (\n        \u003cli key={item.id}\u003e\n          \u003cbutton\n            {...getItemProps(item.id)}\n            style={{ background: item.color }}\n          \u003e\n            \u003cspan\u003e{item.text}\u003c/span\u003e\n          \u003c/button\u003e\n        \u003c/li\u003e\n      ))}\n    \u003c/ul\u003e\n  )\n}\n```\n\n## Props\n\n### initialItems\n\n\u003e Array of objects with each item containing a unique id\n\n### delay\n\n\u003e number, defaults to 250\n\n### debounceMs\n\n\u003e number, defaults to 200\n\n### easeFunction\n\n\u003e string, defaults to a subtle springy `cubic-bezier(.39,.28,.13,1.14)`\n\n## Example\n\n```\ngit clone git@github.com:timc1/react-drag-elements.git\n```\n\n```\ncd react-drag-elements/example\n```\n\n```\nyarn\n```\n\n```\nyarn start\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimc1%2Freact-drag-elements","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimc1%2Freact-drag-elements","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimc1%2Freact-drag-elements/lists"}