Reputation: 6613
We are using dojo dnd package for drag and drop purpose. There is class Moveable which can be used for the moving node element and the code looks like as below
var dropSource = new Moveable(DIV_ID);
and Moving item can be tracked with following line ( using onMove event)
on(dropSource, "Move",some_function);
Is it possible to achieve same thing using dojo/dnd/Source ?
Upvotes: 0
Views: 209
Reputation: 44685
I don't think there is a similar event. However, there is an event that can be used to check if the dragging motion is started (onDndStart
) and there is an event that can be used to check if it stopped, which can be either cancelled or stopped (onMouseUp
).
To check if it's moving you can try to use the onMouseMove
event. The bad thing is that it executes always when moving your mouse over the dojo/dnd/Source
. So to make it work properly you have to check if the user is dragging an element. This only occurs if the onMouseMove
event is between the onDndStart
and onMouseUp
event.
So an example:
var isDragging = false;
on(mySource, "DndStart", function() {
isDragging = true;
});
on(mySource, "MouseUp", function() {
isDragging = false;
});
on(mySource, "MouseMove", function() {
if (isDragging) {
// Now an element is being moved, I think
}
});
I don't know if this covers all cases and I don't think you can actually retrieve the item that is being dragged. I made a JSfiddle that uses these functions in my example above to extend dojo/dnd/Source
to support an onMove
event.
I don't think it's the most neat solution, but if there's one module I really don't like in Dojo (exluding DojoX), then it would be the dojo/dnd
part.
Upvotes: 1