Draggable Widgetversion added: 1.0
Description: 该组件可以让你使用鼠标拖动所有元素。
让被选择元素可以被鼠标拖动。如果你想把元素拖放到另一个元素内部,查看jQuery UI Droppable plugin,该组件为被拖动元素提供了一个目标容器。
Dependencies(依赖性)
Options
addClassesType: Boolean
true
false, ui-draggable样式类将不能被添加引用。当在大量元素上调用.draggable()时,你可能会想要这样设置,作为一个性能优化。
使用addClasses选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置addClasses选项
|
1
2
3
4
5
6
|
|
appendToType: jQuery or Element or Selector or String
"parent"
- jQuery: 一个含有要被添加拖动组件助手的元素的Jquery对象。
- Element: 要被添加拖动组件助手的元素。
- Selector: 一个用来识别要被添加拖动组件助手的元素的选择器。
-
String: 字符串
"parent"将会使拖动组件助手成为组件的同级元素。
使用appendTo选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置appendTo选项
|
1
2
3
4
5
6
|
|
axisType: String
false
"x", "y"。
使用axis选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置axis选项:
|
1
2
3
4
5
6
|
|
cancelType: Selector
"input,textarea,button,select,option"
使用cancel选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置cancel选项:
|
1
2
3
4
5
6
|
|
connectToSortableType: Selector
false
helper选项必须被设置为"clone"。 必须包含jQuery UI 排序组件。使用connectToSortable选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置connectToSortable选项:
|
1
2
3
4
5
6
|
|
containmentType: Selector or Element or String or Array
false
- Selector: 可拖动元素将被置于由选择器指定的第一个元素的起界限作用的盒模型中。如果没有找到任何元素,则不会设置界限。
- Element: 可拖动的元素将包含该元素的边界框。
-
String:可选值:
"parent","document","window". -
Array: 以
[ x1, y1, x2, y2 ]数组形式定义一个限制区域.
使用containment选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置containment选项:
|
1
2
3
4
5
6
|
|
cursorType: String
"auto"
使用cursor选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置cursor选项:
|
1
2
3
4
5
6
|
|
cursorAtType: Object
false
{ top, left, right, bottom }
。使用cursorAt选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置cursorAt选项:
|
1
2
3
4
5
6
|
|
delayType: Number
0
使用delay选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置delay选项:
|
1
2
3
4
5
6
|
|
disabledType: Boolean
false
true,拖动特效将被禁用。使用disabled选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置disabled选项:
|
1
2
3
4
5
6
|
|
distanceType: Number
1
使用distance选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置distance选项:
|
1
2
3
4
5
6
|
|
gridType: Array
false
[ x, y ]。
使用grid选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置grid 选项:
|
1
2
3
4
5
6
|
|
handleType: Selector or Element
false
使用handle选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置handle 选项:
|
1
2
3
4
5
6
|
|
helperType: String or Function()
"original"
-
String:如果值设置为
"clone", 那么该元素将会被复制,并且被复制的元素将被拖动。 - Function: 当拖动时,函数将返回一个DOM元素以供使用。
使用helper选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置helper 选项:
|
1
2
3
4
5
6
|
|
iframeFixType: Boolean or Selector
false
cursorAt选项搭配使用时或者当鼠标指针可能不在拖动助手元素之上时,该参数非常有用。-
Boolean: 当设置为
true, 透明层将被放置于页面上的所有iframe之上。/li> - Selector: 任何由选择器匹配的iframe将被透明层覆盖。
使用iframeFix选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置iframeFix 选项:
|
1
2
3
4
5
6
|
|
opacityType: Number
false
使用opacity选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置opacity 选项:
|
1
2
3
4
5
6
|
|
refreshPositionsType: Boolean
false
true, 所有的可拖动位置在每次鼠标移动时都会被计算。 注意: 这解决了具有高度动态内容页面的问题,但是却降低了性能。
使用refreshPositions选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置refreshPositions 选项:
|
1
2
3
4
5
6
|
|
revertType: Boolean or String
false
-
Boolean: 如果设置为
true,当拖动停止时,元素位置将被重置。 -
String: 如果设置为
"invalid", 重置仅当拖动没有被放置于一个可放置的对象时才会发生。如果设置为"valid", 情况则相反。
使用revert选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置revert 选项:
|
1
2
3
4
5
6
|
|
revertDurationType: Number
500
revert选项设置为false,则忽略(译者注:即被拖到元素不会被重置。)。使用revertDuration选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置revertDuration 选项:
|
1
2
3
4
5
6
|
|
scopeType: String
"default"
accept选项。如果一个一般拖动组件的scope参数值和一个拖动至容器组件的scope参数值一样,那么这个一般拖动组件将被接受为拖动至容器组件。使用scope选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置scope 选项:
|
1
2
3
4
5
6
|
|
scrollType: Boolean
true
true, 当拖动时,div盒模型将自动翻滚。使用scroll选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置scroll 选项:
|
1
2
3
4
5
6
|
|
scrollSensitivityType: Number
20
scroll 选项设置为false,则不滚动。使用scrollSensitivity选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置scrollSensitivity 选项:
|
1
2
3
4
5
6
|
|
scrollSpeedType: Number
20
使用scrollSpeed选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置scrollSpeed 选项:
|
1
2
3
4
5
6
|
|
snapType: Boolean or Selector
false
-
Boolean: 当设置为
true时, 元素将可以吸附到所有其它可拖动元素上。 - Selector: 确定被吸附元素。
使用snap选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置snap 选项:
|
1
2
3
4
5
6
|
|
snapModeType: String
"both"
使用snapMode选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置snapMode 选项:
|
1
2
3
4
5
6
|
|
snapToleranceType: Number
20
snap选项设置为false,则忽略该参数。使用snapTolerance选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置snapTolerance 选项:
|
1
2
3
4
5
6
|
|
stackType: Selector
false
使用stack选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置stack 选项:
|
1
2
3
4
5
6
|
|
zIndexType: Number
false
使用zIndex选项初始化Draggable Widget:
|
1
|
|
在组件初始化之后,读取或设置zIndex 选项:
|
1
2
3
4
5
6
|
|
Methods
destroy()
- 这个方法不接受任何参数。
请求destroy方法:
|
1
|
|
disable()
- 这个方法不接受任何参数。
请求disable方法:
|
1
|
|
enable()
- 这个方法不接受任何参数。
请求enable方法:
|
1
|
|
option( optionName )Returns: Object
optionName对应的参数值。-
optionNameType: String要获取的值所对应的选项的名称。
请求方法:
|
1
|
|
option()Returns: PlainObject
- 这个方法不接受任何参数。
请求方法:
|
1
|
|
option( optionName, value )
optionName指定。请求方法:
|
1
|
|
option( options )
-
optionsType: Object要设置的选项与值之间的映射关系。
请求方法:
|
1
|
|
widget()Returns: jQuery
jQuery对象。
- 这个方法不接受任何参数。
请求widget方法:
|
1
|
|
Events
create( event, ui )Type: dragcreate
注意: ui对象是空的,但是为了与其它元素保持一直,它总是被包含。
使用create回调函数指定事件:
|
1
2
3
|
|
绑定一个事件监听器到dragcreate事件:
|
1
|
|
drag( event, ui )Type: drag
使用drag回调函数指定事件:
|
1
2
3
|
|
绑定一个事件监听者到drag事件:
|
1
|
|
start( event, ui )Type: dragstart
使用start callback specified:
|
1
2
3
|
|
拖动事件绑定一个事件监听器:
|
1
|
|
Example:
一个简单的jQuery UI一般拖动
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
|