说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

Draggable(hash)-JQuery API

HTML文档下载 WORD文档下载 PDF文档下载
Draggable(hash)创建一个可拖放对象,它包含许多高级选项,包括回调,像谷歌地图一样的拖放控制,逆转,充盈,和网格拖放。

Draggable(hash)

创建一个可拖放对象,它包含许多高级选项,包括回调,像谷歌地图一样的拖放控制,逆转,充盈,和网格拖放。

 

返回值

jQuery

 

参数

hash (Hash): A hash of parameters. All parameters are optional. 

Hash 选项

  • handle (String): The jQuery selector matching the handle that starts the draggable
  • handle (DOMElement): The DOM Element of the handle that starts the draggable
  • revert (Boolean): When true, on stop-drag the element returns to initial position
  • ghosting (Boolean): When true, a copy of the element is moved
  • zIndex (Integer): zIndex depth for the element while it is being dragged
  • opacity (Float): A number between 0 and 1 that indicates the opacity of the element while being dragged
  • grid (Integer): A number of pixels indicating the grid that the element should snap to
  • grid (Array): A number of x-pixels and y-pixels indicating the grid that the element should snap to
  • fx (Integer): Duration for the effect (like ghosting or revert) applied to the draggable
  • containment (String): Define the zone where the draggable can be moved. 'parent' moves it inside parent element, while 'document' prevents it from leaving the document and forcing additional scrolling
  • containment (Array): An 4-element array (topm left, width, height) indicating the containment of the element
  • axis (String): Set an axis: vertical (with 'vertically') or horizontal (with 'horizontally')
  • onStart (Function): Callback function triggered when the dragging starts
  • onStop (Function): Callback function triggered when the dragging stops
  • onChange (Function): Callback function triggered when the dragging stop and the element was moved at least one pixel
  • onDrag (Function): Callback function triggered while the element is dragged. Receives two parameters: x and y coordinates. You can return an object with new coordinates {x: x, y: y} so this way you can interact with the dragging process (for instance, build your containment)
  • insideParent (Boolean): Forces the element to remain inside its parent when being dragged (like Google Maps)
  • snapDistance (Integer): The element is not moved unless it is dragged more than snapDistance. You can prevent accidental dragging and keep regular clicking enabled (for links or form elements, for instance)
  • cursorAt (Object): The dragged element is moved to the cursor position with the offset specified. Accepts value for top, left, right and bottom offset. Basically, this forces the cursor to a particular position during the entire drag operation.
  • autoSize (Boolean): When true, the drag helper is resized to its content, instead of the dragged element's sizes 

备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘