jQuery EasyUI 基础插件 - Draggable 可拖动
jQuery EasyUI 教程
· 2019-04-07 10:57:02
通过 $.fn.draggable.defaults 重写默认的 defaults。
用法
通过标记创建可拖动(draggable)元素。
<div id="dd" class="easyui-draggable" data-options="handle:'#title'" style="width:100px;height:100px;">
<div id="title" style="background:#ccc;">title</div>
</div>
使用 javascript 创建可拖动(draggable)元素。
<div id="dd" style="width:100px;height:100px;">
<div id="title" style="background:#ccc;">title</div>
</div>
$('#dd').draggable({
handle:'#title'
});
属性
| 名称 | 类型 | 描述 | 默认值 |
|---|---|---|---|
| proxy | string,function | 拖动时要使用的代理元素,设置为 'clone' 时,克隆元素将被用作代理。如果指定一个函数,它必须返回一个 jQuery 对象。 下面的实例演示了如何创建简单的代理对象。
$('.dragitem').draggable({
proxy: function(source){
var p = $('<div style="border:1px solid #ccc;width:80px"></div>');
p.html($(source).html()).appendTo('body');
return p;
}
});
|
null |
| revert | boolean | 如果设置为 true,拖动结束后元素将返回它的开始位置。 | false |
| cursor | string | 拖动时的 css 光标(cursor)。 | move |
| deltaX | number | 拖动的元素相对于当前光标的 X 轴位置。 | null |
| deltaY | number | 拖动的元素相对于当前光标的 Y 轴位置。 | null |
| handle | selector | 启动可拖动(draggable)的处理(handle)。 | null |
| disabled | boolean | 如果设置为 true,则停止可拖动(draggable)。 | false |
| edge | number | 能够在其中开始可拖动(draggable)的拖动宽度。 | 0 |
| axis | string | 定义拖动元素可在其上移动的轴,可用的值是 'v' 或 'h',当设为 null,将会沿着 'v' 和 'h' 的方向移动。 | null |
事件
| 名称 | 参数 | 描述 |
|---|---|---|
| onBeforeDrag | e | 拖动前触发,返回 false 就取消拖动。 |
| onStartDrag | e | 目标对象开始拖动时触发。 |
| onDrag | e | 拖动期间触发。返回 false 将不进行实际的拖动。 |
| onStopDrag | e | 拖动停止时触发。 |
方法
| 名称 | 参数 | 描述 |
|---|---|---|
| options | none | 返回选项(options)属性(property)。 |
| proxy | none | 如果设置了代理(proxy)属性就返回拖动代理(proxy)。 |
| enable | none | 启用拖动动作。 |
| disable | none | 禁用拖动动作。 |
点击查看所有 jQuery EasyUI 教程 文章: https://codercto.com/courses/l/42.html
Beautiful Code
Greg Wilson、Andy Oram / O'Reilly Media / 2007-7-6 / GBP 35.99
In this unique work, leading computer scientists discuss how they found unusual, carefully designed solutions to difficult problems. This book lets the reader look over the shoulder of major coding an......一起来看看 《Beautiful Code》 这本书的介绍吧!