Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for multiple sortable lists. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion nativesortable.js
@@ -1,4 +1,3 @@

// nativesortable
// Author: Brian Grinstead MIT License
// Originally based on code found here:
Expand Down Expand Up @@ -126,6 +125,8 @@ nativesortable = (function() {
e.dataTransfer.setData('Text', "*"); // Need to set to something or else drag doesn't start
}

// save the current drag item to a global var which can be checked by all native sortable lists on the page
dragitem = this;
currentlyDraggingElement = this;
addClassName(currentlyDraggingElement, DRAGGING_CLASS);

Expand All @@ -151,6 +152,16 @@ nativesortable = (function() {
});

var handleDragEnter = delegate(function(e) {

// check if the drop target is the same list as the draggable item
if (dragitem) {
if (element != dragitem.parentNode) {
// clone the item into the list
currentlyDraggingElement = dragitem.cloneNode(true);
element.appendChild(currentlyDraggingElement);
dragitem = null;
}
}

if (!currentlyDraggingElement || currentlyDraggingElement === this) {
return true;
Expand Down