All Projects → BadhanGanesh → Bjdraggable

BadhanGanesh / Bjdraggable

Licence: mit
A simple Swift protocol utilising the powerful UIKitDynamics API, which makes ANY UIView draggable within a boundary view that acts as collision body, with a single method call. Works for any UIView.

Programming Languages

ruby
36898 projects - #4 most used programming language
swift
15916 projects

Projects that are alternatives of or similar to Bjdraggable

Jsonhelper
✌ Convert anything into anything in one operation; JSON data into class instances, hex strings into UIColor/NSColor, y/n strings to booleans, arrays and dictionaries of these; anything you can make sense of!
Stars: ✭ 792 (+2375%)
Mutual labels:  protocol
Modbus
Modbus RTU and TCP support for C#
Stars: ✭ 23 (-28.12%)
Mutual labels:  protocol
Summer
Decoupled protocol for modules in Android App
Stars: ✭ 19 (-40.62%)
Mutual labels:  protocol
Draggableflagview
可拖拽的红点,(仿新版QQ,tab下面拖拽标记为已读的效果),拖拽一定的距离可以消失回调。
Stars: ✭ 811 (+2434.38%)
Mutual labels:  draggable
Senseme
Python Library for Haiku SenseMe app controlled fans/lights
Stars: ✭ 19 (-40.62%)
Mutual labels:  protocol
Draggablelayout
Draggable XML Layout for Android
Stars: ✭ 26 (-18.75%)
Mutual labels:  draggable
Dragmove.js
A super tiny Javascript library to make DOM elements draggable and movable. ~500 bytes and no dependencies.
Stars: ✭ 757 (+2265.63%)
Mutual labels:  draggable
React Picky Date Time
A react component for date time picker. Online demo examples
Stars: ✭ 31 (-3.12%)
Mutual labels:  draggable
Protobuf Convert
Macros for convenient serialization of Rust data structures into/from Protocol Buffers 3
Stars: ✭ 22 (-31.25%)
Mutual labels:  protocol
Statusprovider
Protocol to handle initial Loadings, Empty Views and Error Handling in a ViewController & views
Stars: ✭ 879 (+2646.88%)
Mutual labels:  protocol
Starscream
Websockets in swift for iOS and OSX
Stars: ✭ 7,105 (+22103.13%)
Mutual labels:  protocol
Node Ntp
⌛️ simple network time protocol implementation for node.js
Stars: ✭ 17 (-46.87%)
Mutual labels:  protocol
Awareness
The new architecture of co-computation for data processing and machine learning.
Stars: ✭ 11 (-65.62%)
Mutual labels:  protocol
Vue Moveable
↔️ ↕️ 🔄 Vue.js wrapper for Moveable
Stars: ✭ 792 (+2375%)
Mutual labels:  draggable
Pay Protocol
fixing the transition to a cashless world
Stars: ✭ 29 (-9.37%)
Mutual labels:  protocol
Scrollbooster
Enjoyable content drag-to-scroll library
Stars: ✭ 775 (+2321.88%)
Mutual labels:  draggable
Formdraggerdemo
一个可在窗体内随意拖动窗体的方案
Stars: ✭ 24 (-25%)
Mutual labels:  draggable
Misp Rfc
Specifications used in the MISP project including MISP core format
Stars: ✭ 31 (-3.12%)
Mutual labels:  protocol
Whatpulse
WhatPulse reverse engineered
Stars: ✭ 30 (-6.25%)
Mutual labels:  protocol
Python Opcua
LGPL Pure Python OPC-UA Client and Server
Stars: ✭ 863 (+2596.88%)
Mutual labels:  protocol

BJDraggable

A simple protocol (No need to subclass, no need to implement methods and properties yourself. Just drop the BJDraggable file into your project) utilizing the powerful UIKitDynamics API, which makes ANY UIView draggable within a boundary view that acts as collision body, with a single method call.

BJDraggable Demo

Installation

Use pod 'BJDraggable'

OR

Drag and Drop the BJDraggable.swift file (Located inside the Source folder in repo.) into your Xcode project.

Usage

  • Just call the addDraggability method on your view and pass in a boundary view and that's it:
override func viewDidLoad() {
    super.viewDidLoad()
    self.loginView.addDraggability(withinView: self.view)
    self.omegaView.addDraggability(withinView: self.omegaContainerView)
    self.omegaContainerView.addDraggability(withinView: self.view)
    self.signupButton.addDraggability(withinView: self.view)
}
  • You can also add margin to your boundary view by passing in a UIEdgeInsets parameter:
self.loginView.addDraggability(withinView: self.view, withMargin: UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10))
  • To stop the dragging ability, simply call removeDraggability method:
@IBAction func removeDraggabilityButtonTouched(_ sender: UIButton) {
    self.loginView.removeDraggability()
    self.omegaView.removeDraggability()
    self.omegaContainerView.removeDraggability()
    self.signupButton.removeDraggability()
}

Note: Call removeDraggability() in the deinit of your UIViewController or UIView if your think you're done with it. This does the cleanup of memory and other variables used.

Optional Usage

  • If you want the view to move to its original position (respecting its autolayout constraints) after removing draggability like in the example GIF above, set the shouldResetViewPositionAfterRemovingDraggability property to true. Default value is false.

  • To visually highlight the boundary lines within which the drag will happen, you can make isDraggableDebugModeEnabled property to true. The effective boundary (with margins applied) will be highlighted in red color. Specifying your own color will be added in the next or subsequent commits.

Limitations

  • Currently, due to the nature of the implementation, the draggability will not work well with rounded-corner views, since invisible walls are drawn around the superview separately in the manner like left, right, top, bottom to simulate boundary.
  • This could be overcome by eliminating the use of imaginary special views and instead, using real boundaries with paths. BUT this method comes with one little caveat that, the view that you're dragging will not slide against the walls, they just stick to it.

License

This code is distributed under the terms and conditions of the MIT license.

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