用法:
containment
默認:
false
將拖動限製在指定元素或區域的範圍內。
支持多種類型:- Selector:可拖動元素將包含在選擇器找到的第一個元素的邊界框內。如果未找到任何元素,則不會設置包含。
- Element:可拖動元素將包含在該元素的邊界框內。
-
String:可能的值:
"parent"
,"document"
,"window"
. -
Array: 一個數組,在表單中定義一個邊界框
[ x1, y1, x2, y2 ]
.
代碼示例:
使用指定的containment
選項初始化可拖動對象:
$( ".selector" ).draggable({
containment: "parent"
});
初始化後獲取或設置containment
選項:
// Getter
var containment = $( ".selector" ).draggable( "option", "containment" );
// Setter
$( ".selector" ).draggable( "option", "containment", "parent" );
相關用法
- JQuery UI Draggable connectToSortable用法及代碼示例
- JQuery UI Draggable cursorAt用法及代碼示例
- JQuery UI Draggable cursor用法及代碼示例
- JQuery UI Draggable classes用法及代碼示例
- JQuery UI Draggable cancel用法及代碼示例
- JQuery UI Draggable create( event, ui )用法及代碼示例
- JQuery UI Draggable snapMode用法及代碼示例
- JQuery UI Draggable snap用法及代碼示例
- JQuery UI Draggable start( event, ui )用法及代碼示例
- JQuery UI Draggable snapTolerance用法及代碼示例
- JQuery UI Draggable option用法及代碼示例
- JQuery UI Draggable disabled用法及代碼示例
- JQuery UI Draggable stop( event, ui )用法及代碼示例
- JQuery UI Draggable revertDuration用法及代碼示例
- JQuery UI Draggable iframeFix用法及代碼示例
- JQuery UI Draggable enable用法及代碼示例
- JQuery UI Draggable drag( event, ui )用法及代碼示例
- JQuery UI Draggable scrollSensitivity用法及代碼示例
- JQuery UI Draggable axis用法及代碼示例
- JQuery UI Draggable scrollSpeed用法及代碼示例
- JQuery UI Draggable appendTo用法及代碼示例
- JQuery UI Draggable zIndex用法及代碼示例
- JQuery UI Draggable destroy用法及代碼示例
- JQuery UI Draggable scroll用法及代碼示例
- JQuery UI Draggable addClasses用法及代碼示例
注:本文由純淨天空篩選整理自jqueryui.com大神的英文原創作品 Draggable containment。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。