mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-15 22:34:51 +00:00
62bb8affa4
* Add data attribute support to button widget * Fix typo * Refactor ready for making mechanism more generic * Apply more generic implementation to multiplate widgets * Refactor to use existing widget.assignAttributes() method * Fix typo * Clarify docs * Update docs * Update select widget to support style.* attributes * Remove obsolete comment * Fixes refresh issues for checkbox and links widgets for data attributes (#7846) * fix: refresh issues with checkbox and links widgets * fix: indenting * Feat: add support for data attributes to Draggable and Droppable widgets (#7845) * Docs clarification * docs: add style and data attributes to Draggable and Droppable widget docs (#7850) * Refactors Select widget to directly create DOM node (#7848) * fix: refactored SelectWidget to directly create DOM nodes * fix: refactored SelectWidget to directly create DOM nodes * fix: improve refresh handling for select widget * Fixes issues in the PR "Button widget data attributes" (#7852) * fix: fixed ordered attributes handling and improved tests to catch event attributes * fix: clean up code from testing * fix: more tests and refactoring * fix: use lowercase when checking for event attribute prefix * fix: use lowercase when checking for event attribute prefix * fix: changed comment wording * fix: minor refactoring * refactor: for brevity --------- Co-authored-by: Saq Imtiaz <saq.imtiaz@gmail.com>
55 lines
4.4 KiB
Plaintext
55 lines
4.4 KiB
Plaintext
caption: draggable
|
|
created: 20170406081938627
|
|
modified: 20231121101431149
|
|
tags: Widgets TriggeringWidgets
|
|
title: DraggableWidget
|
|
type: text/vnd.tiddlywiki
|
|
|
|
The DraggableWidget creates a DOM element that can be dragged by the user. It only works on browsers that support drag and drop, which typically means desktop browsers, but [[there are workarounds|Mobile Drag And Drop Shim Plugin]].
|
|
|
|
The draggable element can be assigned a list of tiddlers that are used as the payload.
|
|
If desired it can invoke actions when dragging starts and when it ends.
|
|
See DragAndDropMechanism for an overview.
|
|
|
|
! Content and Attributes
|
|
|
|
|!Attribute |!Description |
|
|
|tiddler |Optional title of the payload tiddler for the drag |
|
|
|filter |Optional filter defining the payload tiddlers for the drag |
|
|
|tag |Optional tag to override the default "div" element created by the widget|
|
|
|selector|<<.from-version 5.2.2>> Optional CSS Selector to identify a DOM element within the widget that will be used as the drag handle |
|
|
|class |Optional CSS classes to assign to the DOM element created by the widget. The class `tc-draggable` is added to the the DOM element created by the widget unless the <<.param selector>> attribute is used. The class `tc-dragging` is applied to the DOM element created by the widget while the element is being dragged |
|
|
|enable |<<.from-version 5.2.3>> Optional value "no" to disable the draggable functionality (defaults to "yes") |
|
|
|startactions |Optional action string that gets invoked when dragging ''starts'' |
|
|
|endactions |Optional action string that gets invoked when dragging ''ends'' |
|
|
|dragimagetype |<<.from-version "5.2.0">> Optional type of drag image: `dom` (the default) or `blank` to disable the drag image |
|
|
|data-* |<<.from-version "5.3.2">> Optional [[data attributes|https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes]] to be assigned to the HTML element |
|
|
|style.* |<<.from-version "5.3.2">> Optional [[CSS properties|https://developer.mozilla.org/en-US/docs/Web/CSS/Reference]] to be assigned to the HTML element |
|
|
|
|
Either or both of the ''tiddler'' and ''filter'' attributes must be specified in order for there to be a payload to drag.
|
|
|
|
The [[actionTiddler Variable]] is accessible in both //startactions// and //endactions//. It holds the payload tiddler(s) specified through the //tiddler// and //filter// attributes as a [[Title List]] using double square brackets to quote titles that include whitespace.
|
|
|
|
<<.tip """Note that the [[actionTiddler Variable]] holds a [[Title List]] quoted with double square brackets. This is unlike the DroppableWidget which uses the same variable to pass a single unquoted title.""">>
|
|
|
|
<<.tip """When specifying a DOM node to use as the drag handle with the <<.param selector>> attribute, give it the class `tc-draggable` in order for it to have the appropriate cursor and the attribute `draggable` with the value `true` to make it draggable.""">>
|
|
|
|
|
|
The LinkWidget incorporates the functionality of the DraggableWidget via the ''draggable'' attribute.
|
|
|
|
<<.from-version 5.2.3>> The following variables are accessible in the //startactions// and the //endactions//:
|
|
|
|
|!Variables |!Description |
|
|
|`modifier` |The [[modifier Variable]] contains the Modifier Key held while dragging |
|
|
|`dom-*` |All DOM attributes of the node being dragged are made available as variables, with the prefix `dom-` |
|
|
|`tv-popup-coords` |A relative co-ordinate string that can be used with the ActionPopupWidget to trigger a popup at the DOM node matching the selector where the event originated (see [[Coordinate Systems]] for more information) |
|
|
|`tv-popup-abs-coords` |<<.from-version "5.2.4">> An absolute co-ordinate string that can be used with the ActionPopupWidget to trigger a popup at the DOM node matching the selector where the event originated (see [[Coordinate Systems]] for more information) |
|
|
|`tv-selectednode-posx` |`x` offset position of the dragged DOM node |
|
|
|`tv-selectednode-posy` |`y` offset position of the dragged DOM node |
|
|
|`tv-selectednode-width` |`offsetWidth` of the dragged DOM node |
|
|
|`tv-selectednode-height` |`offsetHeight` of the dragged DOM node |
|
|
|`event-fromselected-posx` |`x` position of the event relative to the dragged DOM node |
|
|
|`event-fromselected-posy` |`y` position of the event relative to the dragged DOM node |
|
|
|`event-fromviewport-posx` |`x` position of the event relative to the viewport |
|
|
|`event-fromviewport-posy` |`y` position of the event relative to the viewport |
|