# Sortable
Sortable is a minimalist JavaScript library for reorderable drag-and-drop lists.
Demo: http://rubaxa.github.io/Sortable/
## Features
* Supports touch devices and [modern](http://caniuse.com/#search=drag) browsers (including IE9)
* Can drag from one list to another or within the same list
* CSS animation when moving items
* Supports drag handles *and selectable text* (better than voidberg's html5sortable)
* Smart auto-scrolling
* Built using native HTML5 drag and drop API
* Supports
* [Meteor](https://github.com/SortableJS/meteor-sortablejs)
* AngularJS
* [2.0+](https://github.com/SortableJS/angular-sortablejs)
* [1.*](https://github.com/SortableJS/angular-legacy-sortablejs)
* React
* [ES2015+](https://github.com/SortableJS/react-sortablejs)
* [Mixin](https://github.com/SortableJS/react-mixin-sortablejs)
* [Knockout](https://github.com/SortableJS/knockout-sortablejs)
* [Polymer](https://github.com/SortableJS/polymer-sortablejs)
* [Vue](https://github.com/SortableJS/Vue.Draggable)
* Supports any CSS library, e.g. [Bootstrap](#bs)
* Simple API
* [CDN](#cdn)
* No jQuery (but there is [support](#jq))
<br/>
### Articles
* [Sortable v1.0 — New capabilities](https://github.com/RubaXa/Sortable/wiki/Sortable-v1.0-—-New-capabilities/) (December 22, 2014)
* [Sorting with the help of HTML5 Drag'n'Drop API](https://github.com/RubaXa/Sortable/wiki/Sorting-with-the-help-of-HTML5-Drag'n'Drop-API/) (December 23, 2013)
<br/>
### Install
Via npm
```bash
$ npm install sortablejs --save
```
Via bower:
```bash
$ bower install --save sortablejs
```
<br/>
### Usage
```html
<ul id="items">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
```
```js
var el = document.getElementById('items');
var sortable = Sortable.create(el);
```
You can use any element for the list and its elements, not just `ul`/`li`. Here is an [example with `div`s](http://jsbin.com/qumuwe/edit?html,js,output).
---
### Options
```js
var sortable = new Sortable(el, {
group: "name", // or { name: "...", pull: [true, false, clone], put: [true, false, array] }
sort: true, // sorting inside list
delay: 0, // time in milliseconds to define when the sorting should start
disabled: false, // Disables the sortable if set to true.
store: null, // @see Store
animation: 150, // ms, animation speed moving items when sorting, `0` — without animation
handle: ".my-handle", // Drag handle selector within list items
filter: ".ignore-elements", // Selectors that do not lead to dragging (String or Function)
preventOnFilter: true, // Call `event.preventDefault()` when triggered `filter`
draggable: ".item", // Specifies which items inside the element should be draggable
ghostClass: "sortable-ghost", // Class name for the drop placeholder
chosenClass: "sortable-chosen", // Class name for the chosen item
dragClass: "sortable-drag", // Class name for the dragging item
dataIdAttr: 'data-id',
forceFallback: false, // ignore the HTML5 DnD behaviour and force the fallback to kick in
fallbackClass: "sortable-fallback", // Class name for the cloned DOM Element when using forceFallback
fallbackOnBody: false, // Appends the cloned DOM Element into the Document's Body
fallbackTolerance: 0, // Specify in pixels how far the mouse should move before it's considered as a drag.
scroll: true, // or HTMLElement
scrollFn: function(offsetX, offsetY, originalEvent) { ... }, // if you have custom scrollbar scrollFn may be used for autoscrolling
scrollSensitivity: 30, // px, how near the mouse must be to an edge to start scrolling.
scrollSpeed: 10, // px
setData: function (/** DataTransfer */dataTransfer, /** HTMLElement*/dragEl) {
dataTransfer.setData('Text', dragEl.textContent); // `dataTransfer` object of HTML5 DragEvent
},
// Element is chosen
onChoose: function (/**Event*/evt) {
evt.oldIndex; // element index within parent
},
// Element dragging started
onStart: function (/**Event*/evt) {
evt.oldIndex; // element index within parent
},
// Element dragging ended
onEnd: function (/**Event*/evt) {
evt.oldIndex; // element's old index within parent
evt.newIndex; // element's new index within parent
},
// Element is dropped into the list from another list
onAdd: function (/**Event*/evt) {
var itemEl = evt.item; // dragged HTMLElement
evt.from; // previous list
// + indexes from onEnd
},
// Changed sorting within list
onUpdate: function (/**Event*/evt) {
var itemEl = evt.item; // dragged HTMLElement
// + indexes from onEnd
},
// Called by any change to the list (add / update / remove)
onSort: function (/**Event*/evt) {
// same properties as onUpdate
},
// Element is removed from the list into another list
onRemove: function (/**Event*/evt) {
// same properties as onUpdate
},
// Attempt to drag a filtered element
onFilter: function (/**Event*/evt) {
var itemEl = evt.item; // HTMLElement receiving the `mousedown|tapstart` event.
},
// Event when you move an item in the list or between lists
onMove: function (/**Event*/evt, /**Event*/originalEvent) {
// Example: http://jsbin.com/tuyafe/1/edit?js,output
evt.dragged; // dragged HTMLElement
evt.draggedRect; // TextRectangle {left, top, right и bottom}
evt.related; // HTMLElement on which have guided
evt.relatedRect; // TextRectangle
originalEvent.clientY; // mouse position
// return false; — for cancel
},
// Called when creating a clone of element
onClone: function (/**Event*/evt) {
var origEl = evt.item;
var cloneEl = evt.clone;
}
});
```
---
#### `group` option
To drag elements from one list into another, both lists must have the same `group` value.
You can also define whether lists can give away, give and keep a copy (`clone`), and receive elements.
* name: `String` — group name
* pull: `true|false|'clone'|function` — ability to move from the list. `clone` — copy the item, rather than move.
* put: `true|false|["foo", "bar"]|function` — whether elements can be added from other lists, or an array of group names from which elements can be taken.
* revertClone: `boolean` — revert cloned element to initial position after moving to a another list.
Demo:
- http://jsbin.com/naduvo/edit?js,output
- http://jsbin.com/rusuvot/edit?js,output — use of complex logic in the `pull` and` put`
- http://jsbin.com/magogub/edit?js,output — use `revertClone: true`
---
#### `sort` option
Sorting inside list.
Demo: http://jsbin.com/videzob/edit?html,js,output
---
#### `delay` option
Time in milliseconds to define when the sorting should start.
Demo: http://jsbin.com/xizeh/edit?html,js,output
---
#### `disabled` options
Disables the sortable if set to `true`.
Demo: http://jsbin.com/xiloqu/edit?html,js,output
```js
var sortable = Sortable.create(list);
document.getElementById("switcher").onclick = function () {
var state = sortable.option("disabled"); // get
sortable.option("disabled", !state); // set
};
```
---
#### `handle` option
To make list items draggable, Sortable disables text selection by the user.
That's not always desirable. To allow text selection, define a drag handler,
which is an area of every list element that allows it to be dragged around.
Demo: http://jsbin.com/newize/edit?html,js,output
```js
Sortable.create(el, {
handle: ".my-handle"
});
```
```html
<ul>
<li><span class="my-handle">::</span> list item text one
<li><span class="my-handle">::</span> list item text two
</ul>
```
```css
.my-handle {
cursor: move;
cursor: -webkit-grabbing;
}
```
---
#### `filter` option
```js
Sortable.create(list, {
filter: ".js-remove, .js-edit",
onFilter: function (e
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v1.5.3.zip
共475个文件
php:265个
po:52个
mo:52个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 137 浏览量
2022-04-08
19:36:32
上传
评论
收藏 7.44MB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v1.5.3 WP Sheet Editor - User Profile Pro WP表编辑器 - 用户配置文件Pro" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v1.5.3.zip (475个子文件)
libraries.css 118KB
libraries.css 118KB
libraries.min.css 89KB
libraries.min.css 89KB
styles.css 53KB
styles.css 53KB
styles.min.css 42KB
styles.min.css 42KB
styles.css 1KB
styles.css 1KB
styles.css 1KB
styles.css 711B
styles.css 711B
fontawesome-webfont.eot 162KB
fontawesome-webfont.eot 162KB
drag-down-autofill-demo.gif 105KB
drag-down-autofill-demo.gif 105KB
libraries.js 2.58MB
libraries.js 2.58MB
libraries.min.js 987KB
libraries.min.js 987KB
scripts.js 131KB
scripts.js 131KB
scripts.min.js 65KB
scripts.min.js 65KB
Sortable.js 37KB
Sortable.js 37KB
init.js 24KB
init.js 24KB
jquery.repeater.js 23KB
jquery.repeater.js 23KB
init.js 21KB
init.js 21KB
Sortable.min.js 18KB
Sortable.min.js 18KB
init.js 16KB
jquery.repeater.min.js 11KB
jquery.repeater.min.js 11KB
init.js 10KB
init.js 10KB
init.js 5KB
init.js 5KB
init.js 4KB
init.js 4KB
init.js 4KB
init.js 4KB
init.js 2KB
init.js 1KB
init.js 1KB
init.js 1014B
init.js 1014B
init.js 567B
init.js 567B
init.js 511B
installed.json 2KB
installed.json 2KB
package.json 1KB
package.json 928B
package.json 322B
LICENSE 1KB
LICENSE 1KB
LICENSE 1KB
LICENSE 1KB
README.md 17KB
README.md 17KB
README.md 8KB
README.md 8KB
README.md 8KB
README.md 8KB
vg_sheet_editor-es_EC.mo 176KB
vg_sheet_editor-es_VE.mo 176KB
vg_sheet_editor-es_PR.mo 176KB
vg_sheet_editor-es_MX.mo 176KB
vg_sheet_editor-es_CO.mo 176KB
vg_sheet_editor-es_PE.mo 176KB
vg_sheet_editor-es_AR.mo 176KB
vg_sheet_editor-es_CR.mo 176KB
vg_sheet_editor-es_GT.mo 176KB
vg_sheet_editor-es_UY.mo 176KB
vg_sheet_editor-es_EC.mo 176KB
vg_sheet_editor-es_VE.mo 176KB
vg_sheet_editor-es_PR.mo 176KB
vg_sheet_editor-es_MX.mo 176KB
vg_sheet_editor-es_CO.mo 176KB
vg_sheet_editor-es_PE.mo 176KB
vg_sheet_editor-es_AR.mo 176KB
vg_sheet_editor-es_CR.mo 176KB
vg_sheet_editor-es_GT.mo 176KB
vg_sheet_editor-es_UY.mo 176KB
vg_sheet_editor-es_ES.mo 176KB
vg_sheet_editor-es_ES.mo 176KB
vg_sheet_editor-de_DE_formal.mo 173KB
vg_sheet_editor-de_DE_formal.mo 173KB
vg_sheet_editor-de_DE.mo 172KB
vg_sheet_editor-de_DE.mo 172KB
vg_sheet_editor_posts-de_DE_formal.mo 11KB
vg_sheet_editor_posts-de_DE.mo 11KB
vg_sheet_editor_posts-es_CO.mo 11KB
vg_sheet_editor_posts-es_MX.mo 11KB
vg_sheet_editor_posts-es_PR.mo 11KB
共 475 条
- 1
- 2
- 3
- 4
- 5
资源评论
Lee达森
- 粉丝: 969
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功