Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A tiny, animated, sortable plugin for jQuery, supporting both touch and mouse events.
JavaScript
branch: iecompatibility

This branch is 4 commits behind docubuzz:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
MIT-LICENSE.txt
README.md
touch-sortable.js
touch-sortable.min.js

README.md

touch-sortable.js

Yet another sortable list plugin for jQuery. touch-sortable.js is a tiny ( ~800 bytes minfied and gziped) purpose driven library that helps to create animated sortable lists in a jiffy. Supports both mouse and touch events.

http://docubuzz.github.io/touch-sortable.js

Installation and usage

Include the touch-sortable script after the jQuery library.

<script src="/path/to/touch-sortable.js"></script>

Execute it against a ul element.

$(".sortable").sortable();

Use the onComplete event to know when reordering is completed. Callback returns the list that was reordered.

$(".sortable").sortable({
    onComplete: function(ul){
        // Put your code here!
    }
});

Example

Currently, touch-sortable.js provides support for unordered lists. Define your list as shown. Check out a working example on our demo page.

<ul class="sortable">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>
    <li>Item 4</li>
</ul>

<script src="jquery.sortable.js"></script>
<script>
    $('.sortable').sortable();
</script>

Styling

An element being dragged around has the class inMotion - which can be used to style in css. Touch-sortable.js assumes elements in list are all the same height.

li {
    display:block; padding:10px; margin:5px 0; background:#eee;
}
li.inMotion {
    box-shadow:0 1px 3px rgba(0,0,0,.3);
}

Development

Any feedback to make this plugin better is welcomed!

If you have any pull requests/bug reports, raise them up in the Pull Requests, or Issues.

Authors

Jeremy Huang

Contributors

Ashish Puliyel

License

Released under the MIT license.

Something went wrong with that request. Please try again.