Sortable: Is there a way to style the element that is dragged?

Created on 4 Dec 2014  路  8Comments  路  Source: SortableJS/Sortable

Similar to #144, is there a way to set the style for the element that's being dragged? Currently it looks transparent.

UPDATE: duplicates #53.

Most helpful comment

The setDragImage API call can be used to set the ghost image.

I know about it, already there is a method setData, but it's not what people want.

So, this feature is just not implemented? Are you going to implement it? There is no limitations on DnD API.

I can see that it could be done manually by .addEventListener on every draggable element, like:

var dragIcon = document.createElement('img');
dragIcon.src = 'some_img.png';
var all_draggable_elements = document.getElementsByClassName('draggable_classname');
for (var i = 0; i < all_draggable_elements.length; i++) {
    all_draggable_elements[i].addEventListener('dragstart', function(event) {
        event.dataTransfer.setDragImage(dragIcon, 0, 0);
    });
}

Also there are various ways of customizing.

All 8 comments

No way, it's made by the browser.

Because they do not use Drag'n'Drop API.

The setDragImage API call can be used to set the ghost image.

I know about it, already there is a method setData, but it's not what people want.

This may be an example of how Webix does it with the HTML5 native DnD API: http://docs.webix.com/samples/22_dnd/06_native_dnd.html

The setDragImage API call can be used to set the ghost image.

I know about it, already there is a method setData, but it's not what people want.

So, this feature is just not implemented? Are you going to implement it? There is no limitations on DnD API.

I can see that it could be done manually by .addEventListener on every draggable element, like:

var dragIcon = document.createElement('img');
dragIcon.src = 'some_img.png';
var all_draggable_elements = document.getElementsByClassName('draggable_classname');
for (var i = 0; i < all_draggable_elements.length; i++) {
    all_draggable_elements[i].addEventListener('dragstart', function(event) {
        event.dataTransfer.setDragImage(dragIcon, 0, 0);
    });
}

Also there are various ways of customizing.

i dont know if this is a bug , but when i defined tthis css .sortable-fallback{
visibility:hidden;
}

the element cloned ( follows the pointer) becomes customizable... which is Good, because i was trying hard to find a way to hide that thing...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

binitghetiya picture binitghetiya  路  4Comments

tom-sherman picture tom-sherman  路  3Comments

artaommahe picture artaommahe  路  4Comments

graemegeorge picture graemegeorge  路  4Comments

garygreen picture garygreen  路  3Comments