DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> jquery.ui.draggable中文文檔
jquery.ui.draggable中文文檔
編輯:JQuery特效代碼     
注意事項:
1. 以下格式為既定的格式, 為了統一性, 需要修改時, 大家商議
2. 格式中的所有項都是選填, 如果沒有, 不寫就是了.
3. 由於是XML格式的, 所以, 所有標簽中間填寫文本的地方(最重要是代碼, 一定要加, 不然以後解析有困難), 都需要加上
<!--[CDATA[這中間寫內容]]>
4. 翻譯過程中, 一塊對應的是一個<translate />標簽.
5. 希望大家工作愉快.
代碼如下:
<?xml version="1.0" encoding="UTF-8" ?>
<project>
<translate item="draggable" version="7.1">
<translators>
<translator nickname="selfimpr" name="雷果國" mail="[email protected]" homepage="http://blog.csdn.net/lgg201" qq="285821471" />
</translators>
<relatives>
<depend isitem="false">
<name><![CDATA[jquery]]></name>
<description><![CDATA[jquery的核心庫]]></description>
<url><![CDATA[http://docs.jquery.com]]></url>
</depend>
<depend isitem="false">
<name><![CDATA[jquery.ui.core]]></name>
<description><![CDATA[jquery.ui的核心庫]]></description>
<url><![CDATA[http://jqueryui.com/demos]]></url>
</depend>
</relatives>
<overview>
<original><![CDATA[JQuery UI Draggable插件用來使選中的元素可以通過鼠標拖動.
Draggable的元素受影響css: ui-draggable, 拖動過程中的css: ui-draggable-dragging.
如果需要的不僅僅是拖, 而是一個完整的拖放功能, 請參閱JQuery UI 的Droppable插件, 該插件提供了一個draggable放的目標.
所有的回調函數(start, stop, drag等事件)接受兩個參數:
event: 浏覽器原生的事件
ui: 一個JQuery的ui對象, 其中有以下主要屬性
ui.helper: 正在拖動的元素的JQuery包裝對象, ui.helper.context可以獲取到原生的DOM元素.
ui.position: ui.helper(也就是我們要拖動的元素)相對於父元素(包含自己的元素, 如果是頂層, 對應body)的偏移, 值是一個對象{top, left}----也就是可以用ui.position.top獲取到該元素與父元素的top當前偏移
ui.offset: 與ui.position同意, 這裡表示的是和浏覽器內容區域左上邊界的偏移(注意, 是內容區域, 而不是html的body區域. html的body在默認情況下, 各種浏覽器中都會相對offset有偏移的.)]]></original>
</overview>
<options>
<option name="addClasses" default="true">
<types>
<type name="布爾值"></type>
</types>
<description><![CDATA[用來設置是否給draggable元素通過ui-draggable樣式才裝飾它. 主要為了在通過.draggable()初始化很多(成百個)元素的時候優化性能考慮, 但是, 這個選項的設置, 不會影響ui-draggable-dragging樣式改變拖動過程樣式.
true表示ui-draggable樣式被添加到該元素.
false表示ui-draggable樣式不被添加到該元素.]]></description>
<demos>
<demo>
<comment><![CDATA[將.selector選擇器選中的元素渲染成為一個可拖動控件, 不為其添加ui-draggable樣式]]></comment>
<code><![CDATA[$('.selector').draggable({ addClasses: false });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取.selector選擇器選中的可拖動控件的addClasses選項的值.]]></comment>
<code><![CDATA[var addClasses = $('#draggable').draggable('option', 'addClasses');]]></code>
</demo>
<demo>
<comment><![CDATA[將.selector選擇器選中的可拖動控件的addClasses選項值設置為false.]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'addClasses', false);]]></code>
</demo>
</demos>
</option>
<option name="appendTo" default="parent">
<types>
<type name="DOM元素" />
<type name="選擇器" />
</types>
<description><![CDATA[用來指定控件在拖動過程中ui.helper的容器, 默認情況下, ui.helper使用和初始定義的draggable相同的容器, 也就是其父元素.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ appendTo: 'body' });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var appendTo = $('.selector').draggable('option', 'appendTo');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'appendTo', 'body');.]]></code>
</demo>
</demos>
</option>
<option name="axis" default="false">
<types>
<type name="Boolean">
<options>
<option>
<value><![CDATA[false]]></value>
<comment><![CDATA[既可以水平, 也可以垂直拖動.]]></comment>
</option>
</options>
</type>
<type name="String">
<options>
<option>
<value><![CDATA[x]]></value>
<comment><![CDATA[只能水平拖動]]></comment>
</option>
<option>
<value><![CDATA[y]]></value>
<comment><![CDATA[只能垂直拖動]]></comment>
</option>
</options>
</type>
</types>
<description><![CDATA[約束拖動過程中的取向.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ axis: 'x' });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var axis = $('.selector').draggable('option', 'axis');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'axis', 'x');]]></code>
</demo>
</demos>
</option>
<option name="cancel" default=":input, option">
<types>
<type name="選擇器">
</type>
</types>
<description><![CDATA[通過選擇器指定這類元素不能被渲染成draggable控件.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ cancel: 'button' });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var cancel = $('.selector').draggable('option', 'cancel');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'cancel', 'button');]]></code>
</demo>
</demos>
</option>
<option name="connectToSortable" default="">
<types>
<type name="">
<description><![CDATA[description]]></description>
</type>
</types>
<description><![CDATA[description]]></description>
<demos>
<demo>
<comment><![CDATA[description]]></comment>
<code><![CDATA[description]]></code>
</demo>
</demos>
</option>
<option name="containment" default="false">
<types>
<type name="選擇器">
<description><![CDATA[只能在選擇器約束的元素內拖動]]></description>
</type>
<type name="元素">
<description><![CDATA[只能在給定的元素內拖動]]></description>
</type>
<type name="字符串">
<options>
<option>
<value><![CDATA[parent]]></value>
<comment><![CDATA[只能在父容器內拖動]]></comment>
</option>
<option>
<value><![CDATA[document]]></value>
<comment><![CDATA[在當前html文檔的document下可拖動, 超出浏覽器窗口范圍時, 自動出現滾動條]]></comment>
</option>
<option>
<value><![CDATA[widow]]></value>
<comment><![CDATA[只能在當前浏覽器窗口的內容區域拖動, 拖動超出當前窗口范圍, 不會導致出現滾動條]]></comment>
</option>
</options>
<description><![CDATA[description]]></description>
</type>
<type name="數組">
<description><![CDATA[[x1, y1, x2, y2]以[開始水平坐標, 開始垂直坐標, 結束水平坐標, 結束垂直坐標]的方式劃定一個區域, 只能在此區域內拖動. 這種方式指定時, 值是相對當前浏覽器窗口內容區域左上角的偏移值.]]></description>
</type>
<type name="布爾型">
<options>
<option>
<value><![CDATA[false]]></value>
<comment><![CDATA[不限制拖動的活動范圍]]></comment>
</option>
</options>
</type>
</types>
<description><![CDATA[影響指定可拖動控件的活動區域.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ containment: 'parent' });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var containment = $('.selector').draggable('option', 'containment');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'containment', 'parent');]]></code>
</demo>
</demos>
</option>
<option name="cursor" default="auto">
<types>
<type name="字符串">
</type>
</types>
<description><![CDATA[影響指定可拖動控件在拖動過程中的鼠標樣式, 該樣式設定之後, 需要控件的原始元素支持指定的cursor樣式, 如果指定的值原始元素不支持, 則使用原始元素默認的cursor樣式. 比如, $('input[type=button]').draggable({ cursor: 'crosshair' }); 由於button不支持crosshair這個鼠標樣式, 所以, 會以默認形式顯示.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ cursor: 'crosshair' });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var cursor = $('.selector').draggable('option', 'cursor');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'cursor', 'crosshair');]]></code>
</demo>
</demos>
</option>
<option name="cursorAt" default="false">
<types>
<type name="對象">
<description><![CDATA[通過設置對象的top, left, right, bottom的屬性值中的一個或兩個來確定位置.]]></description>
</type>
</types>
<description><![CDATA[在拖動控件的過程中, 鼠標在控件上顯示的位置, 值為false(默認)時, 從哪裡點擊開始拖動, 鼠標位置就在哪裡, 如果設置了, 就會在一個相對控件自身左上角偏移位置處, 比如: $('.selector').draggable('option', 'cursorAt', {left: 8, top: 8}); 那麼拖動過程中, 鼠標就會在自身的左上角向下向右各偏移8像素處.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ cursor: 'crosshair' });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var cursor = $('.selector').draggable('option', 'cursor');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'cursor', 'crosshair');]]></code>
</demo>
</demos>
</option>
<option name="delay" default="0">
<types>
<type name="整數">
<description><![CDATA[單位是毫秒]]></description>
</type>
</types>
<description><![CDATA[可拖動控件從鼠標左鍵按下開始, 到拖動效果產生的延時. 該選項可以被用來阻止一些不期望的點擊帶來的無效拖動. 具體效果是: 一次拖動, 從鼠標左鍵按下, 到delay指定的時間, 如果鼠標左鍵還沒有松開, 那麼就認為這次拖動有效, 否則, 認為這次拖動無效.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ delay: 500 });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var delay = $('.selector').draggable('option', 'delay');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'delay', 500);]]></code>
</demo>
</demos>
</option>
<option name="distance" default="1">
<types>
<type name="整數">
<description><![CDATA[單位是像素]]></description>
</type>
</types>
<description><![CDATA[可拖動控件從鼠標左鍵按下開始, 到拖動效果產生的時鼠標必須產生的位移. 該選項可以被用來阻止一些不期望的點擊帶來的無效拖動. 具體效果是: 一次拖動, 從鼠標左鍵按下, 只有當鼠標產生的位移達到distance指定的值時, 才認為是有效的拖動.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ distance: 30 });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var distance = $('.selector').draggable('option', 'distance');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'distance', 30);]]></code>
</demo>
</demos>
</option>
<option name="grid" default="false">
<types>
<type name="數組">
<description><![CDATA[[x, y], x代表水平大小, y代表垂直大小, 單位是像素]]></description>
</type>
</types>
<description><![CDATA[可拖動控件拖動時采用grid的方式拖動, 也就是說拖動過程中的單位是guid選項指定的數組描述的格子那麼大.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ grid: [50, 20] });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var grid = $('.selector').draggable('option', 'grid');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'grid', [50, 20]);]]></code>
</demo>
</demos>
</option>
<option name="handle" default="false">
<types>
<type name="選擇器">
<description><![CDATA[選定的內部元素為控制拖動的部件]]></description>
</type>
<type name="元素">
<description><![CDATA[指定的元素為控制拖動的部件]]></description>
</type>
</types>
<description><![CDATA[指定觸發拖動的元素. 用法: 將一個id=window的div設置為可拖動控件, 設置它的handle是該div中的一個id=title的span, 那麼, 就只有在id=title的span上點擊拖動才是有效的. 注意: 該元素一定要是可拖動控件的子元素.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ handle: 'h2' });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var handle = $('.selector').draggable('option', 'handle');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'handle', 'h2');]]></code>
</demo>
</demos>
</option>
<option name="helper" default="original">
<types>
<type name="字符串">
<options>
<option>
<value><![CDATA[original]]></value>
<comment><![CDATA[可拖動控件本身移動]]></comment>
</option>
<option>
<value><![CDATA[clone]]></value>
<comment><![CDATA[將可拖動控件自身克隆一個移動, 自身在原始位置不變]]></comment>
</option>
</options>
<description><![CDATA[description]]></description>
</type>
<type name="函數">
<description><![CDATA[函數則必須返回一個DOM元素: 以函數返回的DOM元素移動展現拖動的過程.]]></description>
</type>
</types>
<description><![CDATA[拖動過程中幫助用戶知道當前拖動位置的元素. 也就是拖動過程中隨鼠標顯示的元素.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ helper: 'clone' });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var helper = $('.selector').draggable('option', 'helper');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'helper', 'clone');]]></code>
</demo>
</demos>
</option>
<option name="iframeFix" default="false">
<types>
<type name="布爾值">
<options>
<option>
<value><![CDATA[true]]></value>
<comment><![CDATA[拖動過程中, 所有的iframe默認mousemove事件被屏蔽]]></comment>
</option>
<option>
<value><![CDATA[false]]></value>
<comment><![CDATA[拖動過程中, 鼠標進入iframe時iframe的mousemove也會做默認事件響應.]]></comment>
</option>
</options>
</type>
<type name="選擇器">
<description><![CDATA[針對選擇到的iframe屏蔽mousemove事件默認響應]]></description>
</type>
</types>
<description><![CDATA[阻止拖動過程中由於鼠標指針在iframe區域移動, iframe對鼠標移動事件的默認響應.
如果設置為true, 將會阻止拖動過程中當前頁面上所有的iframe的mousemove事件, 如果設置一個選擇器, 將會阻止指定的iframe的mousemove事件.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ iframeFix: true });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var iframeFix = $('.selector').draggable('option', 'iframeFix');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'iframeFix', true);]]></code>
</demo>
</demos>
</option>
<option name="opacity" default="false">
<types>
<type name="浮點數值">
<description><![CDATA[不透明度, 數值越小越透明]]></description>
</type>
</types>
<description><![CDATA[拖動過程中helper(拖動時跟隨鼠標移動的控件)的不透明度.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ opacity: 0.35 });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var opacity = $('.selector').draggable('option', 'opacity');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'opacity', 0.35);]]></code>
</demo>
</demos>
</option>
<option name="refreshPositions" default="false">
<types>
<type name="Boolean">
<description><![CDATA[如果設置為true, 所有的droppable位置會在每次mousemove事件中進行計算.]]></description>
</type>
</types>
<description><![CDATA[該選項主要用於解決高級動態頁面展現問題. 慎用.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ refreshPositions: true });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var refreshPositions = $('.selector').draggable('option', 'refreshPositions');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'refreshPositions', true);]]></code>
</demo>
</demos>
</option>
<option name="revert" default="false">
<types>
<type name="Boolean">
<options>
<option>
<value><![CDATA[true]]></value>
<comment><![CDATA[每次拖動停止之後, 元素自動回到原始位置]]></comment>
</option>
<option>
<value><![CDATA[false]]></value>
<comment><![CDATA[拖動之後不會自動回到原始位置.]]></comment>
</option>
</options>
</type>
<type name="字符串">
<options>
<option>
<value><![CDATA[invalid]]></value>
<comment><![CDATA[除非是一個droppable並且被drop(放)成功了, 才不將元素返回到原始位置.]]></comment>
</option>
<option>
<value><![CDATA[valid]]></value>
<comment><![CDATA[除非是放入一個droppable並且被drop(放)成功了, 才不將元素返回到原始位置.]]></comment>
</option>
</options>
</type>
</types>
<description><![CDATA[影響一次拖動之後是否回歸到原始位置.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ revert: true });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var revert = $('.selector').draggable('option', 'revert');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'revert', true);]]></code>
</demo>
</demos>
</option>
<option name="revertDuration" default="500">
<types>
<type name="整數">
</type>
</types>
<description><![CDATA[revert(回歸到原始位置)整個過程需要的時間, 單位是毫秒. 如果設置revert選項設置為false, 則忽略此屬性.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ revertDuration: 1000 });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var revertDuration = $('.selector').draggable('option', 'revertDuration');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'revertDuration', 1000);]]></code>
</demo>
</demos>
</option>
<option name="scope" default="default">
<relatives>
<innerrelative item="droppable" type="option" name="accept"><![CDATA[droppable中accept指定的選擇器選擇到的元素還必須滿足scope相同.]]></innerrelative>
<innerrelative item="droppable" type="option" name="scope"><![CDATA[能夠放入droppable的draggable兩個元素的scope值必須相同.]]></innerrelative>
</relatives>
<types>
<type name="字符串">
</type>
</types>
<description><![CDATA[該選項描述一個范圍, 和droppable的同名選項結合使用, droppable的accept選項用來設置可以接受的draggable控件, 同時, 可接受的drggable控件受scope選項約束, 必須是同一個scope中的draggable和droppable才可以互相拖放.
例如:
$('#draggable_a').draggable({scope: 'a'});
$('#draggable_b').draggable({scope: 'b'});
$('#droppable_a').droppable({scope: 'a'});
$('#droppable_b').droppable({scope: 'b'});
droppable控件的accept選項默認是'*', 看起來數draggable_a, draggable_b可以自由的放入到droppable_a和droppable_b中, 但是, 由於scope的約束, draggable_a只能放入到droppable_a, draggable_b只能發乳到droppable_b中.
注意: 這個選項就和變量的名稱空間的意義類似. 默認值是'default', 說明如果不指定, 大家都還是有scope的, 名字是default而已.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ scope: 'tasks' });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var scope = $('.selector').draggable('option', 'scope');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'scope', 'tasks');]]></code>
</demo>
</demos>
</option>
<option name="scroll" default="true">
<types>
<type name="Boolean">
</type>
</types>
<description><![CDATA[如果設置為true, 在拖動過程中超出可拖動控件容器的時候, 容器自動增加滾動條]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ scroll: false });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var scope = $('.selector').draggable('option', 'scope');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'scroll', false);]]></code>
</demo>
</demos>
</option>
<option name="scrollSensitivity" default="20">
<types>
<type name="整數值">
</type>
</types>
<description><![CDATA[滾動條的敏感度.
下面所屬的鼠標指針是指在draggable控件移動過程中, 鼠標所處位置.
鼠標指針和與draggable控件所在容器的邊距離為多少的時候, 滾動條開始滾動.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ scrollSensitivity: 40 });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var scrollSensitivity = $('.selector').draggable('option', 'scrollSensitivity');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'scrollSensitivity', 40);]]></code>
</demo>
</demos>
</option>
<option name="scrollSpeed" default="20">
<types>
<type name="整數值">
</type>
</types>
<description><![CDATA[由於scrollSensitivity導致的滾動發生時, 滾動條一次滾動多少像素值.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ scrollSpeed: 40 });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var scrollSpeed = $('.selector').draggable('option', 'scrollSpeed');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'scrollSpeed', 40);]]></code>
</demo>
</demos>
</option>
<option name="snap" default="false">
<types>
<type name="Boolean">
<description><![CDATA[設置為true等價與設置選擇器.ui-draggable]]></description>
</type>
<type name="選擇器">
<description><![CDATA[選擇器指定的所有元素上, 當前的draggable控件都可以實現吸附功能]]></description>
</type>
</types>
<description><![CDATA[吸附功能, 設置為true等價與設置選擇器.ui-draggable, 具體效果是在選擇器指定的所有元素上, 當前的draggable控件都可以實現吸附功能, 吸附就是拖動過程中, 靠近但是還沒有挨上目標組件是, 自動的將正在拖動的組件吸過去.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ snap: true });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var snap = $('.selector').draggable('option', 'snap');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'snap', true);]]></code>
</demo>
</demos>
</option>
<option name="snapMode" default="both">
<types>
<type name="字符串">
<options>
<option>
<value><![CDATA[inner]]></value>
<comment><![CDATA[在指定的元素內部可以吸附]]></comment>
</option>
<option>
<value><![CDATA[outer]]></value>
<comment><![CDATA[在指定元素外部可以吸附]]></comment>
</option>
<option>
<value><![CDATA[both]]></value>
<comment><![CDATA[裡面外面都可以吸附]]></comment>
</option>
</options>
</type>
</types>
<description><![CDATA[設定吸附時候的模式.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ snapMode: 'outer' });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var snapMode = $('.selector').draggable('option', 'snapMode');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'snapMode', 'outer');]]></code>
</demo>
</demos>
</option>
<option name="snapTolerance" default="20">
<types>
<type name="整數">
</type>
</types>
<description><![CDATA[設定離目標對象的邊多少像素的時候, 進行吸附.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ snap: true });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var snap = $('.selector').draggable('option', 'snap');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'snap', true);]]></code>
</demo>
</demos>
</option>
<option name="stack" default="false">
<types>
<type name="對象">
<description><![CDATA[{group: '.selector', min: 50} 其中, group制定的是一個選擇器, 用來規定那些對象是一組. min是該組的最小z-index值]]></description>
</type>
</types>
<description><![CDATA[一次初始化一組draggable控件的時候, 將其中的一些draggable控件以給定選擇器選擇, 作為一組, 這時, 這一組draggable控件就可以實現當前被拖動的始終在最前效果, min用來指定這一組的z-index值的最小值.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ stack: { group: 'products', min: 50 } });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var stack = $('.selector').draggable('option', 'stack');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'stack', { group: 'products', min: 50 });]]></code>
</demo>
</demos>
</option>
<option name="zIndex" default="false">
<types>
<type name="整數">
</type>
</types>
<description><![CDATA[拖動時的helper(跟隨鼠標移動的控件)的z-index值. z-index就是css中的層疊層數, 數值越大, 越在上層.]]></description>
<demos>
<demo>
<comment><![CDATA[初始化]]></comment>
<code><![CDATA[$('.selector').draggable({ zIndex: 2700 });]]></code>
</demo>
<demo>
<comment><![CDATA[獲取屬性值]]></comment>
<code><![CDATA[var zIndex = $('.selector').draggable('option', 'zIndex');]]></code>
</demo>
<demo>
<comment><![CDATA[設置屬性值]]></comment>
<code><![CDATA[$('.selector').draggable('option', 'zIndex', 2700);]]></code>
</demo>
</demos>
</option>
</options>
<events>
<event name="start">
<trigger><![CDATA[拖動開始, 指鼠標按下, 開始移動]]></trigger>
<arguments>
<argument name="event">
<![CDATA[原生的浏覽器事件.]]>
</argument>
<argument name="ui">
<![CDATA[JQuery的ui對象]]>
</argument>
</arguments>
<description><![CDATA[類型: dragstart]]></description>
<demos>
<demo>
<comment><![CDATA[初始化時設置事件]]></comment>
<code><![CDATA[$('.selector').draggable({
start: function(event, ui) { alert(this); },
});]]></code>
</demo>
<demo>
<comment><![CDATA[動態的綁定事件. 動態綁定時候, 使用的事件名就是事件的類型.]]></comment>
<code><![CDATA[$(".selector").bind('dragstart', function(event, ui) {
alert(this);
});]]></code>
</demo>
</demos>
</event>
<event name="drag">
<trigger><![CDATA[拖動過程中鼠標移動]]></trigger>
<arguments>
<argument name="event">
<![CDATA[原生的浏覽器事件.]]>
</argument>
<argument name="ui">
<![CDATA[JQuery的ui對象]]>
</argument>
</arguments>
<description><![CDATA[類型: drag]]></description>
<demos>
<demo>
<comment><![CDATA[初始化時設置事件]]></comment>
<code><![CDATA[$('.selector').draggable({
drag: function(event, ui) { alert(this); },
});]]></code>
</demo>
<demo>
<comment><![CDATA[動態的綁定事件. 動態綁定時候, 使用的事件名就是事件的類型.]]></comment>
<code><![CDATA[$(".selector").bind('drag', function(event, ui) {
alert(this);
});]]></code>
</demo>
</demos>
</event>
<event name="stop">
<trigger><![CDATA[拖動結束]]></trigger>
<arguments>
<argument name="event">
<![CDATA[原生的浏覽器事件.]]>
</argument>
<argument name="ui">
<![CDATA[JQuery的ui對象]]>
</argument>
</arguments>
<description><![CDATA[類型: dragstop]]></description>
<demos>
<demo>
<comment><![CDATA[初始化時設置事件]]></comment>
<code><![CDATA[$('.selector').draggable({
stop: function(event, ui) { alert(this); },
});]]></code>
</demo>
<demo>
<comment><![CDATA[動態的綁定事件. 動態綁定時候, 使用的事件名就是事件的類型.]]></comment>
<code><![CDATA[$(".selector").bind('dragstop', function(event, ui) {
alert(this);
});]]></code>
</demo>
</demos>
</event>
</events>
<methods>
<method name="destroy">
<description><![CDATA[完全移除一個可拖動控件, 使其回退到該元素被初始化成可拖動控件之前的狀態.]]></description>
<demos>
<demo>
<code><![CDATA[$(".selector").progressbar('destroy');]]></code>
</demo>
</demos>
</method>
<method name="disable">
<description><![CDATA[將可拖動控件樣式改變成為失效, 與enable對應.]]></description>
<demos>
<demo>
<code><![CDATA[$(".selector").progressbar('disable');]]></code>
</demo>
</demos>
</method>
<method name="enable">
<description><![CDATA[將可拖動控件樣式改變為允許, 與disable對應.]]></description>
<demos>
<demo>
<code><![CDATA[$(".selector").progressbar('enable');]]></code>
</demo>
</demos>
</method>
<method name="option">
<arguments>
<argument name="optionName " type="字符串"><![CDATA[選項一節中列舉的所有選項名都可用]]></argument>
<argument name="value" type="任意"><![CDATA[該選項可以接受的任意數據值.]]></argument>
</arguments>
<description><![CDATA[獲取或設置可拖動控件的選項, 第二個參數是選項名, 第三個參數是值. 如果不指定值, 就是獲取, 指定值, 就是設置. ]]></description>
<demos>
<demo>
<code><![CDATA[$(".selector").progressbar('option', optionName[, value]);]]></code>
</demo>
</demos>
</method>
</methods>
<summarize><![CDATA[addClasses: 用來設置是否添加ui-draggable樣式.
appendTo: 設置追加到什麼地方
axis: 設置拖動的方向
cancel, handle: 設置控制整個控件拖動動作的區域, cancel指定區域不能拖動, handle指定區域控制控件拖動.
connectToSortable: 需要和sortable集成.
containment: 設置控件可拖動范圍
cursor, cursorAt: 設置拖動過程中, 鼠標的樣式及相對空間自身的位置.
delay, distance: 設置拖動的延遲, delay設置延遲時間, distance設置延遲距離, 目的是防止誤點擊帶來的不期望拖動.
grid: 設置拖動過程移動的單位(以小格的方式移動)
helper: 設置拖動過程中, 跟隨鼠標移動的組件.
iframeFix: 解決拖動過程中與iframe層疊後的事件問題.
opacity: 拖動過程helper的不透明度.
refreshPositions: 設置後drop過程中, 鼠標每次移動都會計算位置.
revert, revertDuration: 設置撤銷移動相關.
scope: 設定draggable的域, 用來和droppable結合使用時確定可放入的目標.
scroll, scrollSensitivity, scrollSpeed: 設置拖動過程中帶來的滾動條相關問題.
snap, snapMode, snapTolerance: 設置吸附的相關屬性.
stack, zIndex: 設置控件的層次.
]]--></summarize>
</translate>
</project>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved