Browse Source

#110: + setData (close #111)

pull/126/merge
RubaXa 10 years ago
parent
commit
6d40013fe6
  1. 9
      README.md
  2. 10
      Sortable.js
  3. 2
      Sortable.min.js

9
README.md

@ -1,17 +1,17 @@
# Sortable # Sortable
Sortable is a minimalist JavaScript library for reorderable drag-and-drop lists.
## Features ## Features
* Support touch devices and [modern](http://caniuse.com/#search=drag) browsers * Supports touch devices and [modern](http://caniuse.com/#search=drag) browsers
* Can drag from one list to another or within the same list
* Animation moving items when sorting (css animation) * Animation moving items when sorting (css animation)
* Built using native HTML5 drag and drop API * Built using native HTML5 drag and drop API
* Support [AngularJS](#ng) * Support [AngularJS](#ng)
* Simple API * Simple API
* Lightweight, 2KB gzipped
* No jQuery * No jQuery
### Usage ### Usage
```html ```html
<ul id="items"> <ul id="items">
@ -41,6 +41,9 @@ var sortabel = new Sortable(el, {
filter: ".ignor-elements", // Selectors that do not lead to dragging (String or Function) filter: ".ignor-elements", // Selectors that do not lead to dragging (String or Function)
draggable: ".item", // Specifies which items inside the element should be sortable draggable: ".item", // Specifies which items inside the element should be sortable
ghostClass: "sortable-ghost", ghostClass: "sortable-ghost",
setData: function (dataTransfer, dragEl) {
dataTransfer.setData('Text', dragEl.textContent);
},
onStart: function (/**Event*/evt) { /* dragging */ }, onStart: function (/**Event*/evt) { /* dragging */ },
onEnd: function (/**Event*/evt) { /* dragging */ }, onEnd: function (/**Event*/evt) { /* dragging */ },

10
Sortable.js

@ -84,7 +84,10 @@
ghostClass: 'sortable-ghost', ghostClass: 'sortable-ghost',
ignore: 'a, img', ignore: 'a, img',
filter: null, filter: null,
animation: 0 animation: 0,
setData: function (dataTransfer, dragEl) {
dataTransfer.setData('Text', dragEl.textContent);
}
}; };
@ -304,7 +307,8 @@
_onDragStart: function (evt/**Event*/, isTouch/**Boolean*/){ _onDragStart: function (evt/**Event*/, isTouch/**Boolean*/){
var dataTransfer = evt.dataTransfer; var dataTransfer = evt.dataTransfer,
options = this.options;
this._offUpEvents(); this._offUpEvents();
@ -341,7 +345,7 @@
} }
else { else {
dataTransfer.effectAllowed = 'move'; dataTransfer.effectAllowed = 'move';
dataTransfer.setData('Text', dragEl.textContent); options.setData && options.setData.call(this, dataTransfer, dragEl);
_on(document, 'drop', this._onDrop); _on(document, 'drop', this._onDrop);
} }

2
Sortable.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save