Draggable widget: Add option to hide drag image

Thanks @ericshulman

Fixes #6027
sort-optimisations
jeremy@jermolene.com 2021-09-12 14:20:03 +01:00
rodzic f70cee6907
commit e9e5d37ff0
3 zmienionych plików z 8 dodań i 2 usunięć

Wyświetl plik

@ -16,7 +16,7 @@ Browser data transfer utilities, used with the clipboard and drag and drop
Options:
domNode: dom node to make draggable
dragImageType: "pill" or "dom"
dragImageType: "pill", "blank" or "dom" (the default)
dragTiddlerFn: optional function to retrieve the title of tiddler to drag
dragFilterFn: optional function to retreive the filter defining a list of tiddlers to drag
widget: widget to use as the contect for the filter
@ -73,6 +73,9 @@ exports.makeDraggable = function(options) {
if(dataTransfer.setDragImage) {
if(dragImageType === "pill") {
dataTransfer.setDragImage(dragImage.firstChild,-16,-16);
} else if (dragImageType === "blank") {
dragImage.removeChild(dragImage.firstChild);
dataTransfer.setDragImage(dragImage,0,0);
} else {
var r = domNode.getBoundingClientRect();
dataTransfer.setDragImage(domNode,event.clientX-r.left,event.clientY-r.top);

Wyświetl plik

@ -54,6 +54,7 @@ DraggableWidget.prototype.render = function(parent,nextSibling) {
dragFilterFn: function() {return self.getAttribute("filter");},
startActions: self.startActions,
endActions: self.endActions,
dragImageType: self.dragImageType,
widget: this
});
// Insert the link into the DOM and render any children
@ -71,6 +72,7 @@ DraggableWidget.prototype.execute = function() {
this.draggableClasses = this.getAttribute("class");
this.startActions = this.getAttribute("startactions");
this.endActions = this.getAttribute("endactions");
this.dragImageType = this.getAttribute("dragimagetype");
// Make the child widgets
this.makeChildWidgets();
};

Wyświetl plik

@ -1,6 +1,6 @@
caption: draggable
created: 20170406081938627
modified: 20190118084621046
modified: 20210912141544224
tags: Widgets
title: DraggableWidget
type: text/vnd.tiddlywiki
@ -20,6 +20,7 @@ See DragAndDropMechanism for an overview.
|tag |Optional tag to override the default "div" element |
|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 |
Either or both of the ''tiddler'' and ''filter'' attributes must be specified in order for there to be a payload to drag.