All Projects → mmick66 → Kddraganddropcollectionview

mmick66 / Kddraganddropcollectionview

Licence: mit
This component allows for the transfer of data items between collection views through drag and drop

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Kddraganddropcollectionview

KDRearrangeableCollectionViewFlowLayout
A Drag and Rearrange UICollectionView through its layout
Stars: ✭ 73 (-84.66%)
Mutual labels:  uicollectionview, drag-and-drop, drag, drop
Angular Skyhook
An implementation of react-dnd for Angular.
Stars: ✭ 146 (-69.33%)
Mutual labels:  drag-and-drop, drag, drop
vue-simple-upload-component
A simple upload component for Vue.js 2.x
Stars: ✭ 14 (-97.06%)
Mutual labels:  drag-and-drop, drag, drop
image-uploader
Simple Drag & Drop image uploader plugin to static forms, without using AJAX
Stars: ✭ 70 (-85.29%)
Mutual labels:  drag-and-drop, drag, drop
React Smooth Dnd
react wrapper components for smooth-dnd
Stars: ✭ 1,560 (+227.73%)
Mutual labels:  drag-and-drop, drag, drop
Gong Wpf Dragdrop
The GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF
Stars: ✭ 1,669 (+250.63%)
Mutual labels:  drag-and-drop, drag, drop
Smooth Dnd
drag and drop library for javascript
Stars: ✭ 408 (-14.29%)
Mutual labels:  drag-and-drop, drag, drop
Ngx Smooth Dnd
angular wrapper for smooth-dnd
Stars: ✭ 152 (-68.07%)
Mutual labels:  drag-and-drop, drag, drop
DragDropiOS
DragDropiOS is a drag and drop manager on iOS. It supports drag and drop with in one or more classes extends UIView. This library contains UICollectionView and UITableView that implenment of drag and drop manager.
Stars: ✭ 71 (-85.08%)
Mutual labels:  drag-and-drop, drag, drop
solid-dnd
A lightweight, performant, extensible drag and drop toolkit for Solid JS.
Stars: ✭ 251 (-47.27%)
Mutual labels:  drag-and-drop, drag, drop
drop
A LÖVE visualizer and music player
Stars: ✭ 17 (-96.43%)
Mutual labels:  drag-and-drop, drag, drop
Vue Smooth Dnd
Vue wrapper components for smooth-dnd
Stars: ✭ 1,121 (+135.5%)
Mutual labels:  drag-and-drop, drag, drop
Ng2 Dnd
Angular 2 Drag-and-Drop without dependencies
Stars: ✭ 861 (+80.88%)
Mutual labels:  drag-and-drop, drag, drop
rc-dock
Dock Layout for React Component
Stars: ✭ 318 (-33.19%)
Mutual labels:  drag-and-drop, drag, drop
react-native-dnd-board
A drag and drop Kanban board for React Native.
Stars: ✭ 41 (-91.39%)
Mutual labels:  drag-and-drop, drag, drop
KanbanDragDropiOS
Kanban Board using Drag & Drop iOS API
Stars: ✭ 95 (-80.04%)
Mutual labels:  drag-and-drop, drag, drop
dockview
Zero dependency layout manager and builder with ReactJS support
Stars: ✭ 45 (-90.55%)
Mutual labels:  drag-and-drop, drag, drop
navbuilder
Generiert frei definierbare Navigationsbäume mittels Drag & Drop
Stars: ✭ 21 (-95.59%)
Mutual labels:  drag, drop
Windows11DragAndDropToTaskbarFix
"Windows 11 Drag & Drop to the Taskbar (Fix)" fixes the missing "Drag & Drop to the Taskbar" support in Windows 11. It works with the new Windows 11 taskbar and does not require nasty changes like UndockingDisabled or restoration of the classic taskbar.
Stars: ✭ 1,089 (+128.78%)
Mutual labels:  drag, drop
jOrgChart
Here more functionality of jquery orgchart with json support
Stars: ✭ 29 (-93.91%)
Mutual labels:  drag, drop

Drag and Drop Collection Views

Written for Swift 4.0, it is an implementation of Dragging and Dropping data across multiple UICollectionViews.

Drag and Drop Illustration

Try it on Appetize.io!

Language Licence CocoaPods Awesome

Requirements

  • iOS 8.0+
  • XCode 9.0+
  • Swift 4.0 +

Installation

Cocoa Pods

pod 'KDDragAndDropCollectionViews', '~> 1.5.2'

Manual

Add the files in Classes/ to your project.

Quick Guide

Make the UICollectionView of interest a KDDragAndDropCollectionView

XCode Interface Builder Screen

Then set a class as dataSource implementing the KDDragAndDropCollectionViewDataSource protocol.

class ViewController: UIViewController, KDDragAndDropCollectionViewDataSource {

    @IBOutlet weak var firstCollectionView: KDDragAndDropCollectionView!
    @IBOutlet weak var secondCollectionView: KDDragAndDropCollectionView!
    @IBOutlet weak var thirdCollectionView: KDDragAndDropCollectionView!
    
    var data : [[DataItem]] = [[DataItem]]() // just for this example
    
    var dragAndDropManager : KDDragAndDropManager?
    
    override func viewDidLoad() {
        let all = [firstCollectionView, secondCollectionView, thirdCollectionView]
        self.dragAndDropManager = KDDragAndDropManager(canvas: self.view, collectionViews: all)
    }
}

The only responsibility of the user code is to manage the data that the collection view cells are representing. The data source of the collection views must implement the KDDragAndDropCollectionViewDataSource protocol.

In the example we have 3 UICollectionViews distinguishable by their tags (bad practice, I know... but it's only an example ;-) and a data array holding 3 arrays respectively. In a case like this, an implementation of the above could be:

func collectionView(collectionView: UICollectionView, dataItemForIndexPath indexPath: NSIndexPath) -> AnyObject {
    return data[collectionView.tag][indexPath.item]
}

func collectionView(collectionView: UICollectionView, insertDataItem dataItem : AnyObject, atIndexPath indexPath: NSIndexPath) -> Void {
    if let di = dataItem as? DataItem {
        data[collectionView.tag].insert(di, atIndex: indexPath.item)
    }
}

func collectionView(collectionView: UICollectionView, deleteDataItemAtIndexPath indexPath : NSIndexPath) -> Void {
    data[collectionView.tag].removeAtIndex(indexPath.item)
}

func collectionView(collectionView: UICollectionView, moveDataItemFromIndexPath from: NSIndexPath, toIndexPath to : NSIndexPath) -> Void {
    let fromDataItem: DataItem = data[collectionView.tag][from.item]
    data[collectionView.tag].removeAtIndex(from.item)
    data[collectionView.tag].insert(fromDataItem, atIndex: to.item)    
}

func collectionView(_ collectionView: UICollectionView, indexPathForDataItem dataItem: AnyObject) -> IndexPath? {

    guard let candidate = dataItem as? DataItem else { return nil }
    
    for (i,item) in data[collectionView.tag].enumerated() {
        if candidate != item { continue }
        return IndexPath(item: i, section: 0)
    }
    return nil
}

Advanced Use

Prevent specific Items from being Dragged and/or Dropped

For a finer tuning on what items are draggable and which ones are not we can implement the following function from the KDDragAndDropCollectionViewDataSource protocol

func collectionView(_ collectionView: UICollectionView, cellIsDraggableAtIndexPath indexPath: IndexPath) -> Bool {
    return indexPath.row % 2 == 0
}

Data Items and Equatable

In the example code included in this project, I have created a DataItem class to represent the data displayed by the collection view.

class DataItem : Equatable {
    var indexes: String
    var colour: UIColor
    init(indexes: String, colour: UIColor = UIColor.clear) {
        self.indexes    = indexes
        self.colour     = colour
    }
    static func ==(lhs: DataItem, rhs: DataItem) -> Bool {
        return lhs.indexes == rhs.indexes && lhs.colour == rhs.colour
    }
}

In the course of development you will be making your own types that must comform to the Equatable protocol as above. Each data item must be uniquely idenfyiable so be careful when creating cells that can have duplicate display values as for example a "Scrabble" type game where the same letter appears more than once. In cases like these, a simple identifier will do to implement the equality.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].