All Projects → frenetisch-applaudierend → Ios Drag And Drop

frenetisch-applaudierend / Ios Drag And Drop

Licence: mit
A library that helps you support drag and drop operations in your iOS applications.

Projects that are alternatives of or similar to Ios Drag And Drop

Svgdragtree
一个可以通过拖放 SVG 图标,来生成拥有树状结构的视图与数据的前端组件。 SDT example:
Stars: ✭ 113 (+135.42%)
Mutual labels:  drag-drop
plasmic
Visual page builder and web design tool for any website or web app tech stack
Stars: ✭ 1,475 (+2972.92%)
Mutual labels:  drag-drop
Hwpanmodal
HWPanModal presents controller from bottom and drag to dismiss, high customize. iOS13 default modalPresentationStyle. 任意形式的底部弹框动画;头条、知乎、抖音弹出评论效果;地图浮层,iOS13 present默认模态效果。
Stars: ✭ 713 (+1385.42%)
Mutual labels:  drag-drop
Ng Drag Drop
Drag & Drop for Angular - based on HTML5 with no external dependencies. 🎉
Stars: ✭ 233 (+385.42%)
Mutual labels:  drag-drop
ember-dragula
Simple drag and drop with dragula and ember
Stars: ✭ 27 (-43.75%)
Mutual labels:  drag-drop
Drag Drop
HTML5 drag & drop for humans
Stars: ✭ 443 (+822.92%)
Mutual labels:  drag-drop
The Drag And Drop Component Suite For Delphi
Stars: ✭ 109 (+127.08%)
Mutual labels:  drag-drop
Dom Examples
Code examples that accompany various MDN DOM and Web API documentation pages
Stars: ✭ 984 (+1950%)
Mutual labels:  drag-drop
transmat
Share data beyond the browser boundaries. Enable users to transfer data to external apps, and open your webapp to receive external data.
Stars: ✭ 453 (+843.75%)
Mutual labels:  drag-drop
Dragact
a dragger layout system with React style .
Stars: ✭ 710 (+1379.17%)
Mutual labels:  drag-drop
react-page-maker
A drag-drop featured lib which will help you to build the layout and generate the markup or JSON out of it
Stars: ✭ 59 (+22.92%)
Mutual labels:  drag-drop
klatexformula
Generate images from LaTeX equations that you can drag and drop, copy and paste or save to disk.
Stars: ✭ 70 (+45.83%)
Mutual labels:  drag-drop
Dragula
👌 Drag and drop so simple it hurts
Stars: ✭ 21,011 (+43672.92%)
Mutual labels:  drag-drop
Gong Wpf Dragdrop
The GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF
Stars: ✭ 1,669 (+3377.08%)
Mutual labels:  drag-drop
Simplerecyclerview
A RecyclerView extension for building list more easily.
Stars: ✭ 953 (+1885.42%)
Mutual labels:  drag-drop
React Smooth Dnd
react wrapper components for smooth-dnd
Stars: ✭ 1,560 (+3150%)
Mutual labels:  drag-drop
Vvvebjs
Drag and drop website builder javascript library.
Stars: ✭ 4,609 (+9502.08%)
Mutual labels:  drag-drop
Thsidebar
NSOutlineView and badge
Stars: ✭ 38 (-20.83%)
Mutual labels:  drag-drop
Silex
Silex is a static website builder in the cloud.
Stars: ✭ 958 (+1895.83%)
Mutual labels:  drag-drop
Sortable
Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.
Stars: ✭ 23,641 (+49152.08%)
Mutual labels:  drag-drop

iOS Drag and Drop Library

This is a library that helps you support drag and drop operations in your iOS applications. This software is licensed under a MIT license (see the LICENSE file for more info).

Installation

To install it using CococaPods add the following to your Podfile:

pod 'DNDDragAndDrop', '~> 1.4'

Thanks to Hok Shun Poon for providing the podspec.

Usage

The main class to interact with is the DNDDragAndDropController. You provide the controller with two kinds of views to work with:

  • Drag Sources: These are the views that can be used to begin a dragging operation
  • Drop Targets: These are the views where you can drop something

Registering

When registering you need to provide a delegate for both. The DNDDragSourceDelegate is responsible for providing a view that can be dragged around the screen and to handle when a dragging operation was canceled. The DNDDropTargetDelegate on the other hand is used to react to events related to the drop target, like the user entering or leaving the region of a drop target with his fingers, or that a view was just dropped onto a target.

self.dragAndDropController = [[DNDDragAndDropController alloc] init];
[self.dragAndDropController registerDragSource:mySourceView withDelegate:self];
[self.dragAndDropController registerDropTarget:myDropTarget withDelegate:self];

If necessary you can provide your own gesture recognizer for dragging. The passed recognizer must be a continuous gesture recognizer (like a UIPanGestureRecognizer).

[self.dragAndDropController registerDragSource:mySourceView withDelegate:self dragRecognizer:myRecognizer];

By default a UIPanGestureRecognizer is used.

Dragging

To interact, the user will start panning over a drag source, which in turn will ask the delegate to provide a view to be used while dragging around. You provide one with the -draggingViewForDragOperation: method declared in the DNDDragSourceDelegate protocol.

- (UIView *)draggingViewForDragOperation:(DNDDragOperation *)operation {
    // Create a drag view
    CGRect frame = CGRectMake(0.0f, 0.0f, 150.0f, 75.0f);
    UIView *dragView = [[UIView alloc] initWithFrame:frame];
    dragView.backgroundColor = [UIColor orangeColor];
    
    // Let it fade in
    dragView.alpha = 0.0f;
    [UIView animateWithDuration:0.2 animations:^{
        dragView.alpha = 1.0f;
    }];
    
    return dragView;
}

If you would like to have the dragged view appear animated, you can do so directly in this method.

Now the user moves the drag view around the screen. When the drag view enters or leaves a registered drop target, the respective delegate methods from DNDDropTargetDelegate are called. You can for example change the appearance of the target view in these methods.

- (void)dragOperation:(DNDDragOperation *)operation didEnterDropTarget:(UIView *)target {
    target.layer.borderColor = [operation.draggingView.backgroundColor CGColor];
}

- (void)dragOperation:(DNDDragOperation *)operation didLeaveDropTarget:(UIView *)target {
    target.layer.borderColor = [[UIColor whiteColor] CGColor];
}

Dropping

When the user now drops the drag view at some point, one of two things will happen.

If the drag view was dropped above a vaild drop target, the method -dragOperation:didDropInDropTarget: of the drop targets delegate will be called. You can use this method for one to implement anything that needs to happen when a view is dropped on this target, and secondly for example to animate the removal of the drag view.

- (void)dragOperation:(DNDDragOperation *)operation didDropInDropTarget:(UIView *)target {
    // Fade out
    [operation removeDraggingViewAnimatedWithDuration:0.2 animations:^(UIView *dv) {
        dv.alpha = 0.0f;
    }];
}

If the drag view was dropped outside any valid drop targets then the drag was canceled and the drag source delegate is notified of this fact using the -dragOperationWillCancel: delegate method. Analog to dropping on a target, you use this method to implement anything related to cancelling a drag and to animate the removal of the drag view.

- (void)dragOperationWillCancel:(DNDDragOperation *)operation {
    [operation removeDraggingViewAnimatedWithDuration:0.2 animations:^(UIView *dv) {
        dv.alpha = 0.0f;
        dv.center = self.dragSourceView.center; // jump back to the source view
    }];
}

Removing a drag view

To remove a drag view (either in -dragOperation:didDropInDropTarget: or in -dragOperationWillCancel:) you have a few options on DNDDragOperation.

If you don't do anything until the method returns, then by default for both methods the operations -removeDraggingView is called which removes the drag view without any animations.

If you'd like to animate the removal you can use -removeDraggingViewAnimatedWithDuration:animations: which allows you to pass an animation block.

Third, for most control you can use the -beginRemovingDraggingView/-completeRemovingDraggingView method pair. Once you called -beginRemovingDraggingView the dragging view is considered "being removed" and you can return from the method without a default action happening. Then at any point you can remove the dragging view by calling -completeRemovingDraggingView. This can be useful if you need to chain animations for example.

Examples

Check the iOS Sample Application project for a few samples of simple drag and drop operations.

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