diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cab04be --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Created by .ignore support plugin (hsz.mobi) +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio + +## Directory-based project format: +.idea/ \ No newline at end of file diff --git a/README.md b/README.md index a16b7fd..9fcbfac 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,43 @@ #jquery-dragarrange -### A very basic jQuery plugin to shift element position by drag +### A jQuery plugin to shift element position by drag & drop -If you are looking for a library which can be ordered/arranged by drag, you are at right place. This plugin doesn't require any CSS change, just call the function on elements you want to be arranged, and you are done. +If you are looking for a library which can be ordered/arranged by drag, you are at right place. +This plugin doesn't require any CSS change, just call the function on elements you want to be arranged, and you are done. +The intent of the plugin is to: + +* Allow easy drag and drop reordering of elements within a container +* Allow for elements added dynamically to also be sortable +* Automatically scroll when reaching window border for long lists How to Use ---------- ```html
-$('.draggable-element').arrangeable(); --
-$('li').arrangeable({dragSelector: '.drag-area'}); --
A simple jQuery plugin to allow sorting of a group of elements by drag and drop.
+ +Elements can be rearranged within their container by dragging and dropping.
+ +
+ $('.ex1 .draggable-element').dragArrange('.ex1 .draggable-element');
+
+ This example demonstrates that elements can be dragged back and forth between different containers. Each container is + the direct parent of the elements it contains. However, a containerSelector option is specified to encompass both, + thus allowing movement between the two.
+ +
+ $('.ex2 .draggable-element').dragArrange('.ex2 .draggable-element', {containerSelector : '.showcase-2'});
+
+ This example uses a very long unordered list. The length is to demonstrate the auto scroll feature. The draggable items + also have a selector specified to define the drag handle.
+
+ $('.set.drag-list li').dragArrange('.set.drag-list li', {dragSelector : '.drag-area'});
+
+ Elements added to the container inherit the behaviors as long as they match the selector defined. Use the Add an item! + button below to create dynamic elements.
+ + +
+ // List items added to .addable.drag-list will inherit behavior
+ $('.addable.drag-list li').dragArrange('.addable.drag-list li', {dragSelector : '.drag-area'});
+
+ By default, the item being dragged will temporarily have a CSS class added to it to allow custom styling. + Examples 1-4 above apply the following styles to the default dragging class:
+ +
+ .dragging { opacity:0.8; transform:rotate(-1deg); }
+
+ Should this class name conflict with others, or if you wish to style some differently, you may provide a prefix as an option.
+ +
+ $('.ex5 .draggable-element').dragArrange('.ex5 .draggable-element', {cssPrefix : 'stooges_'});
+
+