All Projects → mmick66 → KDRearrangeableCollectionViewFlowLayout

mmick66 / KDRearrangeableCollectionViewFlowLayout

Licence: MIT license
A Drag and Rearrange UICollectionView through its layout

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to KDRearrangeableCollectionViewFlowLayout

Kddraganddropcollectionview
This component allows for the transfer of data items between collection views through drag and drop
Stars: ✭ 476 (+552.05%)
Mutual labels:  uicollectionview, drag-and-drop, drag, drop
Ng2 Dnd
Angular 2 Drag-and-Drop without dependencies
Stars: ✭ 861 (+1079.45%)
Mutual labels:  drag-and-drop, drag, drop
react-native-dnd-board
A drag and drop Kanban board for React Native.
Stars: ✭ 41 (-43.84%)
Mutual labels:  drag-and-drop, drag, drop
solid-dnd
A lightweight, performant, extensible drag and drop toolkit for Solid JS.
Stars: ✭ 251 (+243.84%)
Mutual labels:  drag-and-drop, drag, drop
image-uploader
Simple Drag & Drop image uploader plugin to static forms, without using AJAX
Stars: ✭ 70 (-4.11%)
Mutual labels:  drag-and-drop, drag, drop
Smooth Dnd
drag and drop library for javascript
Stars: ✭ 408 (+458.9%)
Mutual labels:  drag-and-drop, drag, drop
Vue Smooth Dnd
Vue wrapper components for smooth-dnd
Stars: ✭ 1,121 (+1435.62%)
Mutual labels:  drag-and-drop, drag, drop
KanbanDragDropiOS
Kanban Board using Drag & Drop iOS API
Stars: ✭ 95 (+30.14%)
Mutual labels:  drag-and-drop, drag, drop
Angular Skyhook
An implementation of react-dnd for Angular.
Stars: ✭ 146 (+100%)
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 (+2186.3%)
Mutual labels:  drag-and-drop, drag, drop
vue-simple-upload-component
A simple upload component for Vue.js 2.x
Stars: ✭ 14 (-80.82%)
Mutual labels:  drag-and-drop, drag, drop
drop
A LÖVE visualizer and music player
Stars: ✭ 17 (-76.71%)
Mutual labels:  drag-and-drop, drag, drop
rc-dock
Dock Layout for React Component
Stars: ✭ 318 (+335.62%)
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 (-2.74%)
Mutual labels:  drag-and-drop, drag, drop
React Smooth Dnd
react wrapper components for smooth-dnd
Stars: ✭ 1,560 (+2036.99%)
Mutual labels:  drag-and-drop, drag, drop
Ngx Smooth Dnd
angular wrapper for smooth-dnd
Stars: ✭ 152 (+108.22%)
Mutual labels:  drag-and-drop, drag, drop
dockview
Zero dependency layout manager and builder with ReactJS support
Stars: ✭ 45 (-38.36%)
Mutual labels:  drag-and-drop, drag, drop
Lxreorderablecollectionviewflowlayout
Extends `UICollectionViewFlowLayout` to support reordering of cells. Similar to long press and pan on books in iBook.
Stars: ✭ 1,831 (+2408.22%)
Mutual labels:  uicollectionview, drag-and-drop
Bmlongpressdragcellcollectionview
🎉 🎉 🎉 🎉 🎉 让你轻松实现类似支付宝的拖拽重排功能, 支持各种自定义操作。
Stars: ✭ 1,090 (+1393.15%)
Mutual labels:  uicollectionview, drag
Bmdragcellcollectionview Swift
🎉 iOS UICollectionView UICollectionViewCell long press to drag the reorder framework Swift Version
Stars: ✭ 212 (+190.41%)
Mutual labels:  uicollectionview, drag

KDRearrangeableCollectionViewFlowLayout

This is a simple implementation of a drag and rearrange collection view through its layout. It works for UICollectionViews with multiple sections.

Video Demo: Here

Tip: For drag and drop between multiple collection views look at the project here.

Quick Guide

  1. Add the KDRearrangeableCollectionViewFlowLayout.swift file to your project (it is the only file you need).

  2. Set the layout of your UICollectionView to be the one in the file above. This can be done either programmatically or through the Storyboard.

  3. Make the data source of your UICollectionView to be KDRearrangeableCollectionViewDelegate subclass and implement the one mandatory method there.

func moveDataItem(fromIndexPath : NSIndexPath, toIndexPath: NSIndexPath) -> Void

An example implementation for a multisectioned UICollectionView is here:

func moveDataItem(fromIndexPath : NSIndexPath, toIndexPath: NSIndexPath) -> Void {
    let name = self.data[fromIndexPath.section][fromIndexPath.item]
    self.data[fromIndexPath.section].removeAtIndex(fromIndexPath.item)
    self.data[toIndexPath.section].insert(name, atIndex: toIndexPath.item)
}

You can stop the dragging behaviour by setting the property

self.collectionViewRearrangeableLayout.draggable = true

You can constraint the axist of the drag through an enum

self.collectionViewRearrangeableLayout.axis = .Free
self.collectionViewRearrangeableLayout.axis = .X
self.collectionViewRearrangeableLayout.axis = .Y

You can prevent the of any cell by implementing:

func canMoveItem(at indexPath : IndexPath) -> Bool

KDRearrangeableCollectionViewCell

Another class that comes with this package is KDRearrangeableCollectionViewCell. It is a subclass of UICollectionViewCell and it implements a boolean property called 'dragging'. If you choose to make the cells of your collection view a subclass of KDRearrangeableCollectionViewCell this property will be set upon the start and end of the dragging and by overriding it you can set the style of the snapshot image that will be dragged around.

This method will be called before the visual swap happens.

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].