Open ikegami opened 5 years ago
Perhaps there can be a deselectZone
HTMLElement option that, if clicked, will deselect all elements in that sortable.
Perhaps there can be a
deselectZone
HTMLElement option that, if clicked, will deselect all elements in that sortable.
I'm not sure how that pertains to what I suggested?
Note that what you suggest is already trivially easy to produce:
$button.click(
(evt) => {
$('> .sortable-selected', $sortable).each(
(i, child) => {
Sortable.utils.deselect(child);
}
)
);
Right now, I'm using the following hack to achieve the requested enhancement:
// Prevent deselection on external click.
// HACK
let deselectMultiDrag = sortable.multiDrag._deselectMultiDrag;
document.removeEventListener('pointerup', deselectMultiDrag, false);
document.removeEventListener('mouseup', deselectMultiDrag, false);
document.removeEventListener('touchend', deselectMultiDrag, false);
@ikegami It does pertain to what you suggest because the deselectZone
option would be the document
by default, and then when it is changed to another element, the multi drag elements would only get deselected when that element is clicked (as opposed to clicking anywhere on the document).
ah, I see what you mean. That would indeed be a suitable interface.
has this deselectZone
been implemented?
Another possible solution would be to add a class such as multidrag-click-ignore
(or a data-
attribute) to elements within the document that ought to be ignored when a click even is registered coming from them.
my current solution to this issue is to stop the event propagation on the specific element I wish to interact with without deselecting the items,
$(element).on('pointerup mouseup touchend', function(event){
event.stopPropagation();
});
But it seems it still cannot stop deselection while clicking on scrollBar Is it possible to make the feature of deselecting option while clicking empty space as one of config options. If true, deselect the multi drag option, otherwise no reaction,
likely you are not catching the event on the right element. You'll need to inspect your scroll bar and check which element is firing the event. It is possible there are more than one. You could bind an event callback on the document itself to see where your event is coming from.
Hi! Could you please add an option to the MultiDrag plugin that disables deselecting of objects (i.e. avoids calling _deselectMultiDrag). It would be nice to have buttons that interact with the selected objects.