{"id":4156,"url":"https://github.com/SHISME/react-native-draggable-grid","last_synced_at":"2025-08-04T00:32:41.482Z","repository":{"id":33056748,"uuid":"148474892","full_name":"SHISME/react-native-draggable-grid","owner":"SHISME","description":"A draggable and sortable grid of react-native","archived":false,"fork":false,"pushed_at":"2024-03-28T02:50:03.000Z","size":2582,"stargazers_count":320,"open_issues_count":53,"forks_count":95,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-28T14:04:38.080Z","etag":null,"topics":["react-native","react-native-component","react-native-draggable"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SHISME.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-09-12T12:12:48.000Z","updated_at":"2024-11-26T23:26:24.000Z","dependencies_parsed_at":"2024-01-08T01:02:27.632Z","dependency_job_id":"29be5026-09ff-40ef-b1c3-873a3884634d","html_url":"https://github.com/SHISME/react-native-draggable-grid","commit_stats":{"total_commits":52,"total_committers":8,"mean_commits":6.5,"dds":"0.21153846153846156","last_synced_commit":"a2a03a0970638ad5ad00a6e5d3e98eaac72edd66"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SHISME%2Freact-native-draggable-grid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SHISME%2Freact-native-draggable-grid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SHISME%2Freact-native-draggable-grid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SHISME%2Freact-native-draggable-grid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SHISME","download_url":"https://codeload.github.com/SHISME/react-native-draggable-grid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228576898,"owners_count":17939645,"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":["react-native","react-native-component","react-native-draggable"],"created_at":"2024-01-05T20:17:02.831Z","updated_at":"2024-12-07T07:31:33.032Z","avatar_url":"https://github.com/SHISME.png","language":"TypeScript","readme":"# react-native-draggable-grid\n\n[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu) [![LICENSE](https://img.shields.io/badge/license-NPL%20(The%20996%20Prohibited%20License)-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)\n\n\n[中文文档](./README_CN.md)\n\n## Demo\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Issue Stats\" width=\"400\" src=\"https://github.com/SHISME/react-native-draggable-grid/blob/master/example.gif?raw=true\"\u003e\n\u003c/p\u003e\n\n\n## Getting Started\n\n## Installation\n\n```bash\nnpm install react-native-draggable-grid --save\n```\n\n## Usage\n\n```javascript\n\nimport React from 'react';\nimport {\n  View,\n  StyleSheet,\n  Text,\n} from 'react-native';\nimport { DraggableGrid } from 'react-native-draggable-grid';\n\ninterface MyTestProps {\n\n}\n\ninterface MyTestState {\n  data:{key:string, name:string}[];\n}\n\nexport class MyTest extends React.Component\u003cMyTestProps, MyTestState\u003e{\n\n  constructor(props:MyTestProps) {\n    super(props);\n    this.state = {\n      data:[\n        {name:'1',key:'one'},\n        {name:'2',key:'two'},\n        {name:'3',key:'three'},\n        {name:'4',key:'four'},\n        {name:'5',key:'five'},\n        {name:'6',key:'six'},\n        {name:'7',key:'seven'},\n        {name:'8',key:'eight'},\n        {name:'9',key:'night'},\n        {name:'0',key:'zero'},\n      ],\n    };\n  }\n\n  public render_item(item:{name:string, key:string}) {\n    return (\n      \u003cView\n        style={styles.item}\n        key={item.key}\n      \u003e\n        \u003cText style={styles.item_text}\u003e{item.name}\u003c/Text\u003e\n      \u003c/View\u003e\n    );\n  }\n\n  render() {\n    return (\n      \u003cView style={styles.wrapper}\u003e\n        \u003cDraggableGrid\n          numColumns={4}\n          renderItem={this.render_item}\n          data={this.state.data}\n          onDragRelease={(data) =\u003e {\n            this.setState({data});// need reset the props data sort after drag release\n          }}\n        /\u003e\n      \u003c/View\u003e\n    );\n  }\n}\n\nconst styles = StyleSheet.create({\n  button:{\n    width:150,\n    height:100,\n    backgroundColor:'blue',\n  },\n  wrapper:{\n    paddingTop:100,\n    width:'100%',\n    height:'100%',\n    justifyContent:'center',\n  },\n  item:{\n    width:100,\n    height:100,\n    borderRadius:8,\n    backgroundColor:'red',\n    justifyContent:'center',\n    alignItems:'center',\n  },\n  item_text:{\n    fontSize:40,\n    color:'#FFFFFF',\n  },\n});\n\n\n```\n\n## Props\n\n| parameter  | type   | required | description |\n| :--------  | :----  | :------- | :---------- |\n| numColumns | number | yes      | how many items should be render on one row|\n| data       | array  | yes      | data's item must have unique key，item's render will depend on the key|\n| renderItem |(item, order:number) =\u003e ReactElement| yes | Takes an item from data and renders it into the list |\n| itemHeight | number | no       | if not set this, it will the same as itemWidth |\n| dragStartAnimation | object | no | custom drag start animation |\n| style      | object | no       | grid styles |\n\n## Event Props\n\n\n| parameter  | type   | required | description                                                                   |\n| :--------  | :----  | :------- |:------------------------------------------------------------------------------|\n| onItemPress | (item) =\u003e void | no      | Function will execute when item on press                                      |\n| onDragStart | (startDragItem) =\u003e void | no | Function will execute when item start drag                                    |\n| onDragRelease | (data) =\u003e void | no | Function will execute when item release, and will return the new ordered data |\n| onResetSort | (data) =\u003e void | no | Function will execute when dragged item change sort                           |\n| onDragging | (gestureState: PanResponderGestureState) =\u003e void| no | Function will execute when dragging item                                      |\n| onDragItemActive | (item) =\u003e void| no | Function will execute when any item active                                    |\n\n## Item Props\n\n| parameter  | type   | required | description |\n| :--------  | :----  | :------- | :---------- |\n| disabledDrag | boolean | no      | It will disable drag for the item |\n| disabledReSorted | boolean | no | It will disable resort the item |\n\nif you set disabledResorted be true, it will look like that\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Issue Stats\" width=\"400\" src=\"https://github.com/SHISME/react-native-draggable-grid/blob/master/example2.gif?raw=true\"\u003e\n\u003c/p\u003e\n\n\n## Custom Drag Start Animation\n\nIf you want to use your custom animation, you can do like this\n\n```javascript\n\n render() {\n    return (\n      \u003cView style={styles.wrapper}\u003e\n        \u003cDraggableGrid\n          numColumns={4}\n          renderItem={this.render_item}\n          data={this.state.data}\n          onDragStart={this.onDragStart}\n          dragStartAnimation={{\n            transform:[\n              {scale:this.state.animatedValue}\n            ],\n          }}\n        /\u003e\n      \u003c/View\u003e\n    );\n  }\n\n  private onDragStart = () =\u003e {\n    this.state.animatedValue.setValue(1);\n    Animated.timing(this.state.animatedValue, {\n      toValue:3,\n      duration:400,\n    }).start();\n  }\n\n```\n\n## Resort item\n\nif you want resort item yourself,you only need change the data's sort, and the draggable-grid will auto resort by your data.\n\n\u003e the data's key must unique\n","funding_links":[],"categories":["Components"],"sub_categories":["UI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSHISME%2Freact-native-draggable-grid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSHISME%2Freact-native-draggable-grid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSHISME%2Freact-native-draggable-grid/lists"}