Giter VIP home page Giter VIP logo

o5faruk / draggablesortablegridlibrary Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unicorncoderforever/draggablesortablegridlibrary

0.0 0.0 0.0 16.57 MB

A Sample React Native Library for Draggable Sortable Grid , Performs operations like re ordering grid items, deleting grid items ,merging grid items(similar to launcher animation)

TypeScript 80.47% JavaScript 2.94% Python 4.45% Java 3.26% Objective-C 8.88%

draggablesortablegridlibrary's Introduction

DragDropLibrary

A Sample React Native Library for Draggable Sortable Grid , Performs operations like

  • re-ordering grid items,
  • deleting animation grid items
  • merge animation for grid items

Issue Stats

Library Installation

npm i react-native-drag-drop-grid-library --save

Sample Implementation

Suppose alphabets is an array of objects

 this.alphabets = ['1','2','3','4','5','6',
   '7','8','9','10','11','12',
   '13','14','15','16','17','18',
   '19','20','21','22','23','24'];

Features:

  • Sortable(Draggable) Grid feature:
render(){
<View style={{ flex: 1 }}>
<DragDropGrid
     ref={sortGrid => {
       this.sortGrid = sortGrid;
     }}
     blockTransitionDuration={400}
     activeBlockCenteringDuration={200}
     itemsPerRow={4}
     dragActivationTreshold={200}
     onDragRelease   = { (itemOrder) => console.log("Drag was released, the blocks are in the following order: ", itemOrder)       }   
     onDragStart = { (key)          => console.log("Some block is being dragged now!",key) }>
       {
         this.alphabets.map( (letter, index) =>
           <View key={letter} style={[styles.block, { backgroundColor: this.getColor() }]}
           >
           <Text
            style={{color: 'white', fontSize: 50}}>{letter}</Text>
           </View>
         )
       }
    </DragDropGrid>
    </View>
}
    
  • Merge on Grid Item Overlap
render(){
 <View style={{ flex: 1 }}>
     <DragDropGrid
      ref={sortGrid => {
        this.sortGrid = sortGrid;
      }}
      blockTransitionDuration={400}
      activeBlockCenteringDuration={200}
      itemsPerRow={4}
      dragActivationTreshold={200}
      onDragRelease   = { (itemOrder) => console.log("Drag was released, the blocks are in the following order: ", itemOrder)       }   
      onDragStart = { (key)          => console.log("Some block is being dragged now!",key) }   
      onMerge = {(itemKey,mergeBlockKey) => console.log("item and merge item",itemKey,mergeBlockKey)}
      merge={true}>
        {
          this.alphabets.map( (letter, index) =>
            <View key={letter} style={[styles.block, { backgroundColor: this.getColor() }]}
            >
            <Text
             style={{color: 'white', fontSize: 50}}>{letter}</Text>
            </View>
          )
        }
      </DragDropGrid>
    </View>
  }
  • Delete Grid Items
onRemove(letter){
this.sortGrid.deleteBlockList(letter);
}


render() {
    return (
    <View style={{ flex: 1 }}>
    <DragDropGrid
    ref={sortGrid => {
      this.sortGrid = sortGrid;
    }}
      blockTransitionDuration={400}
      activeBlockCenteringDuration={200}
      itemsPerRow={4}
      dragActivationTreshold={200}
      onDragRelease   = { (itemOrder) => console.log("Drag was released, the blocks are in the following order: ",itemOrder)}       onDragStart = { (key)          => console.log("Some block is being dragged now!",key) }   
      onDeleteItem   = { (item) => console.log("Item was deleted:", item) }>
        {
          this.alphabets.map( (letter, index) =>
            <View key={letter} style={[styles.block, { backgroundColor: this.getColor() }]}
            >
            <Text
             style={{color: 'white', fontSize: 50}}>{letter}</Text>
              <View style={[styles.close]}>
              <TouchableOpacity
              activeOpacity={0.5}
              onPress={()=> this.onRemove(letter)}>
              <View
              style={[
              styles.circle,
              { width: 25, height: 25, backgroundColor: '#1A325E' },
              this.props.style
              ]}
              >
             <Image resizeMode="contain" style={{ height: 19 }} source={require('./assets/close_white.png')} />
            </View>
            </TouchableOpacity>
            </View>
            </View>
          )
        }
      </DragDropGrid>
      </View>
    )
  }
  

draggablesortablegridlibrary's People

Contributors

unicorncoderforever avatar sfirleaalex avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.