所有的事件回调函数都有两个参数:event和ui,浏览器自有event对象,和经过封装的ui对象
ui.helper - 表示sortable元素的JQuery对象,通常是当前元素的克隆对象
ui.position - 表示相对当前对象,鼠标的坐标值对象{top,left}
ui.offset - 表示相对于当前页面,鼠标的坐标值对象{top,left}
ui.item - 表示当前拖拽的元素
ui.placeholder - 占位符(如果有定义的话)
ui.sender - 当前拖拽元素的所属sortable对象(仅当元素是从另一个sortable对象传递过来时有用)

·参数(参数名 : 参数类型 : 默认值)
appendTo : String : 'parent'
Defines where the helper that moves with the mouse is being appended to during the drag (for example, to resolve overlap/zIndex issues).
初始:$('.selector').sortable({ appendTo: 'body' });
获取:var appendTo = $('.selector').sortable('option', 'appendTo');
设置:$('.selector').sortable('option', 'appendTo', 'body');

axis : String : false
如果有设置,则元素仅能横向或纵向拖动。可选值:'x', 'y'
初始:$('.selector').sortable({ axis: 'x' });
获取:var axis = $('.selector').sortable('option', 'axis');
设置:$('.selector').sortable('option', 'axis', 'x');

cancel : Selector : ':input,button'
阻止排序动作在匹配的元素上发生。
初始:$('.selector').sortable({ cancel: 'button' });
获取:var cancel = $('.selector').sortable('option', 'cancel');
设置:$('.selector').sortable('option', 'cancel', 'button');

connectWith : Selector : false
允许sortable对象连接另一个sortable对象,可将item元素拖拽到另一个中。
初始:$('.selector').sortable({ connectWith: '.otherlist' });
获取:var connectWith = $('.selector').sortable('option', 'connectWith');
设置:$('.selector').sortable('option', 'connectWith', '.otherlist');

containment : Element, String, Selector : false
约束排序动作只能在一个指定的范围内发生。可选值:DOM对象, 'parent', 'document', 'window', 或jQuery对象
初始:$('.selector').sortable({ containment: 'parent' });
获取:var containment = $('.selector').sortable('option', 'containment');
设置:$('.selector').sortable('option', 'containment', 'parent');

cursor : String : 'auto'
定义在开始排序动作时,如果的样式。
初始:$('.selector').sortable({ cursor: 'crosshair' });
获取:var cursor = $('.selector').sortable('option', 'cursor');
设置:$('.selector').sortable('option', 'cursor', 'crosshair');

cursorAt : Object : false
当开始移动时,鼠标定位在的某个位置上(最多两个方向)。可选值:{ top, left, right, bottom }.
初始:$('.selector').sortable({ cursorAt: 'top' });
获取:var cursorAt = $('.selector').sortable('option', 'cursorAt');
设置:$('.selector').sortable('option', 'cursorAt', 'top');

delay : Integer : 0
以毫秒为单位,设置延迟多久才激活排序动作。此参数可防止误点击。
初始:$('.selector').sortable({ delay: 500 });
获取:var delay = $('.selector').sortable('option', 'delay');
设置:$('.selector').sortable('option', 'delay', 500);

distance : Integer : 1
决定至少要在元素上面拖动多少像素后,才正式触发排序动作。
初始:$('.selector').sortable({ distance: 30 });
获取:var distance = $('.selector').sortable('option', 'distance');
设置:$('.selector').sortable('option', 'distance', 30);

dropOnEmpty : Boolean : true
是否允許拖拽到一個空的sortable对象中。
初始:$('.selector').sortable({ dropOnEmpty: false });
获取:var dropOnEmpty = $('.selector').sortable('option', 'dropOnEmpty');
设置:$('.selector').sortable('option', 'dropOnEmpty', false);

forceHelperSize : Boolean : false
If true, forces the helper to have a size.
初始:$('.selector').sortable({ forceHelperSize: true });
获取:var forceHelperSize = $('.selector').sortable('option', 'forceHelperSize');
设置:$('.selector').sortable('option', 'forceHelperSize', true);

forcePlaceholderSize : Boolean : false
If true, forces the placeholder to have a size.
初始:$('.selector').sortable({ forcePlaceholderSize: true });
获取:var forcePlaceholderSize = $('.selector').sortable('option', 'forcePlaceholderSize');
设置:$('.selector').sortable('option', 'forcePlaceholderSize', true);

grid : Array : false
将排序对象的item元素视为一个格子处理,每次移动都按一个格子大小移动,数组值:[x,y]
初始:$(’.selector’).sortable({ grid: [50, 20] });
获取:var grid = $(’.selector’).sortable(’option’, ‘grid’);
设置:$(’.selector’).sortable(’option’, ‘grid’, [50, 20]);

handle : Selector, Element : false
限制排序的动作只能在item元素中的某个元素开始。
初始:$(’.selector’).sortable({ handle: ‘h2′ });
获取:var handle = $(’.selector’).sortable(’option’, ‘handle’);
设置:$(’.selector’).sortable(’option’, ‘handle’, ‘h2′);

helper : String, Function : ‘original’
设置是否在拖拽元素时,显示一个辅助的元素。可选值:’original’, ‘clone’
初始:$(’.selector’).sortable({ helper: ‘clone’ });
获取:var helper = $(’.selector’).sortable(’option’, ‘helper’);
设置:$(’.selector’).sortable(’option’, ‘helper’, ‘clone’);

items : Selector : ‘> *’
指定在排序对象中,哪些元素是可以进行拖拽排序的。
初始:$(’.selector’).sortable({ items: ‘li’ });
获取:var items = $(’.selector’).sortable(’option’, ‘items’);
设置:$(’.selector’).sortable(’option’, ‘items’, ‘li’);

opacity : Float : false
定义当排序时,辅助元素(helper)显示的透明度。
初始:$(’.selector’).sortable({ opacity: 0.6 });
获取:var opacity = $(’.selector’).sortable(’option’, ‘opacity’);
设置:$(’.selector’).sortable(’option’, ‘opacity’, 0.6);

placeholderType: StringDefault: false
设置当排序动作发生时,空白占位符的CSS样式。
初始:$(’.selector’).sortable({ placeholder: ‘ui-state-highlight’ });
获取:var placeholder = $(’.selector’).sortable(’option’, ‘placeholder’);
设置:$(’.selector’).sortable(’option’, ‘placeholder’, ‘ui-state-highlight’);

revert : Boolean : false
如果设置成true,则被拖拽的元素在返回新位置时,会有一个动画效果。
初始:$(’.selector’).sortable({ revert: true });
获取:var revert = $(’.selector’).sortable(’option’, ‘revert’);
设置:$(’.selector’).sortable(’option’, ‘revert’, true);

scroll : Boolean : true
如果设置成true,则元素被拖动到页面边缘时,会自动滚动。
初始:$(’.selector’).sortable({ scroll: false });
获取:var scroll = $(’.selector’).sortable(’option’, ’scroll’);
设置:$(’.selector’).sortable(’option’, ’scroll’, false);

scrollSensitivity : Integer : 20
设置当元素移动至边缘多少像素时,便开始滚动页面。
初始:$(’.selector’).sortable({ scrollSensitivity: 40 });
获取:var scrollSensitivity = $(’.selector’).sortable(’option’, ’scrollSensitivity’);
设置:$(’.selector’).sortable(’option’, ’scrollSensitivity’, 40);

scrollSpeed : Integer : 20
设置页面滚动的速度。
初始:$(’.selector’).sortable({ scrollSpeed: 40 });
获取:var scrollSpeed = $(’.selector’).sortable(’option’, ’scrollSpeed’);
设置:$(’.selector’).sortable(’option’, ’scrollSpeed’, 40);

tolerance : String : ‘intersect’
设置当拖动元素越过其它元素多少时便对元素进行重新排序。可选值:’intersect’, ‘pointer’
intersect:至少重叠50%
pointer:鼠标指针重叠元素
初始:$(’.selector’).sortable({ tolerance: ‘pointer’ });
获取:var tolerance = $(’.selector’).sortable(’option’, ‘tolerance’);
设置:$(’.selector’).sortable(’option’, ‘tolerance’, ‘pointer’);

zIndex : Integer : 1000
设置在排序动作发生时,元素的z-index值。
初始:$(’.selector’).sortable({ zIndex: 5 });
获取:var zIndex = $(’.selector’).sortable(’option’, ‘zIndex’);
设置:$(’.selector’).sortable(’option’, ‘zIndex’, 5);

·事件

start
当排序动作开始时触发此事件。
定义:$(’.selector’).sortable({ start: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sortstart’, function(event, ui) { … });

sort
当元素发生排序时触发此事件。
定义:$(’.selector’).sortable({ sort: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sort’, function(event, ui) { … });

change
当元素发生排序且坐标已发生改变时触发此事件。
定义:$(’.selector’).sortable({ change: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sortchange’, function(event, ui) { … });

beforeStop
当排序动作结束之前触发此事件。此时占位符元素和辅助元素仍有效。
定义:$(’.selector’).sortable({ beforeStop: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sortbeforeStop’, function(event, ui) { … });

stop
当排序动作结束时触发此事件。
定义:$(’.selector’).sortable({ stop: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sortstop’, function(event, ui) { … });

update
当排序动作结束时且元素坐标已经发生改变时触发此事件。
定义:$(’.selector’).sortable({ update: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sortupdate’, function(event, ui) { … });

receive
当一个已连接的sortable对象接收到另一个sortable对象的元素后触发此事件。
定义:$(’.selector’).sortable({ receive: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sortreceive’, function(event, ui) { … });

over
当一个元素拖拽移入另一个sortable对象后触发此事件。
定义:$(’.selector’).sortable({ over: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sortover’, function(event, ui) { … });

out
当一个元素拖拽移出sortable对象移出并进入另一个sortable对象后触发此事件。
定义:$(’.selector’).sortable({ out: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sortout’, function(event, ui) { … });

activate
当一个有使用连接的sortable对象开始排序动作时,所有允许的sortable触发此事件。
定义:$(’.selector’).sortable({ activate: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sortactivate’, function(event, ui) { … });

deactivate
当一个有使用连接的sortable对象结束排序动作时,所有允许的sortable触发此事件。
定义:$(’.selector’).sortable({ deactivate: function(event, ui) { … } });
绑定:$(’.selector’).bind(’sortdeactivate’, function(event, ui) { … });

·方法

destory
从元素中移除拖拽功能。
用法:.sortable( ‘destroy’ )

disable
禁用元素的拖拽功能。
用法:.sortable( ‘disable’ )

enable
启用元素的拖拽功能。
用法:.sortable( ‘enable’ )

option
获取或设置元素的参数。
用法:.sortable( ‘option’ , optionName , [value] )

serialize
获取或设置序列化后的每个item元素的id属性。
用法:.sortable( ’serialize’ , [options] )

toArray
获取序列化后的每个item元素的id属性的数组。
用法:.sortable( ‘toArray’ )

refresh
手动重新刷新当前sortable对象的item元素的排序。
用法:.sortable( ‘refresh’ )

refreshPositions
手动重新刷新当前sortable对象的item元素的坐标,此方法可能会降低性能。
用法:.sortable( ‘refreshPositions’ )

cancel
取消当前sortable对象中item元素的排序改变。
用法:.sortable( ‘cancel’ )

Sortable.js参数的更多相关文章

  1. html5 Sortable.js 拖拽排序源码分析

    最近公司项目经常用到一个拖拽 Sortable.js插件,所以有空的时候看了 Sortable.js 源码,总共1300多行这样,写的挺完美的.   本帖属于原创,转载请出名出处. 官网http:// ...

  2. 拖放排序插件Sortable.js 兼容好及功能全个人觉得比dragula.js 好的多

    经测试,Sortable.js 兼容好和使用方便都是比较不错的,特别手机端使用很棒 介绍 Sortable.js是一款轻量级的拖放排序列表的js插件(虽然体积小,但是功能很强大)下载地址:https: ...

  3. Sortable.js

    拖拽的时候主要由这几个事件完成, ondragstart 事件:当拖拽元素开始被拖拽的时候触发的事件,此事件作用在被拖曳元素上 ondragenter 事件:当拖曳元素进入目标元素的时候触发的事件,此 ...

  4. html5支持drag的拖放排序插件sortable.js

    html5支持drag的拖放排序插件sortable.js <script src="//cdnjs.cloudflare.com/ajax/libs/Sortable/1.5.1/S ...

  5. js参数arguments的理解

    原文地址:js参数arguments的理解 对于函数的参数而言,如下例子 function say(name, msg){ alert(name + 'say' + msg); } say('xiao ...

  6. js实现table排序-sortable.js

    方案一.引用sortable.js包 /* <th class="thcss" style="width: 40px;" onclick="so ...

  7. vuejs2.0使用Sortable.js实现的拖拽功能

    简介 在使用vue1.x之前的版本的时候,页面中的拖拽功能,我在项目中是直接用的jquery ui中的sortable.js,只是在拖拽完成后,在update的回调函数中又重新排序了存放数据的数组.但 ...

  8. Vue.Draggable:基于 Sortable.js 的 Vue 拖拽组件使用中遇到的问题

    Sortable.js 介绍 https://segmentfault.com/a/1190000008209715 项目中遇到的问题: A - 我需要在项目的拖拽组件中,使用背景 1 - 想到的第一 ...

  9. vue2.0使用Sortable.js实现的拖拽功能

    简介 在使用vue1.x之前的版本的时候,页面中的拖拽功能,我在项目中是直接用的jQuery ui中的sortable.js,只是在拖拽完成后,在update的回调函数中又重新排序了存放数据的数组.但 ...

随机推荐

  1. html5实现拖拽上传头像

    1. 将客户端(本地电脑)中的图片拖到网页中 要点: html5 拖放, FileReader html: <div id="container" ondrop=" ...

  2. Beta阶段综合报告

    一. 敏捷冲刺每日报告 http://www.cnblogs.com/mia0502/p/7767628.html http://www.cnblogs.com/mia0502/p/7773872.h ...

  3. Android 7.0+相机、相册、裁剪适配问题

    Android 7.0+相机.相册.裁剪适配问题 在manifest中: <provider android:name="android.support.v4.content.File ...

  4. 转Git学习碰到的问题

    [原]Git学习碰到的问题 1.通过 windows 下的 gitbash 连接 github 时 $ ssh-keygen -t rsa -C "abcd@efgh.com" / ...

  5. Linux命令(十四) 查看工作目录文件 ls

    目录 1.命令简介 2.常用参数介绍 3.实例 4.直达底部 命令简介 ls 命令是 Linux 下最常用的命令. ls 就是 list 的缩写.默认情况下 ls 命令用来打印出当前目录的清单, 如果 ...

  6. [知乎]关于WindowsXPx64SP2系统的说明

    自己简单安装了下发现 winxpsp3x86的系统版本为: 然后windowsXPx64sp2的版本为:   作者:qpi667链接:https://www.zhihu.com/question/29 ...

  7. PPT 遥控器

    1. 下载 最新版本: 百度袋鼠输入: http://daishu.baidu.com/?from=pptweb 百度PPT遥控器:http://ppt.baidu.com/ 2. 安装过程忽略 3. ...

  8. SpringBoot 5.SpringBoot小知识讲解

    1.修改 server 端口: 在 application.properties 中添加 server.port=9090,我们的端口号就会变成9090了. 2.自定义配置Web: 2.1 创建 Cu ...

  9. postman 学习网址

    postman使用详解: http://gold.xitu.io/entry/57597a62a341310061337885 https://www.getpostman.com/docs/writ ...

  10. java虚拟机的内存划分

    为了提高运算效率,就对空间进行不同区域的划分,因为每一片区域都有特定的处理数据方式和内存管理方式. 一. 1.jvm的内存划分: 区域名称 作用 寄存器 给cpu使用,和我们开发无关 本地方法栈 jv ...