tracking mouse coordinates during dock drag

0 Answers 14 Views
Dock
Dave
Top achievements
Rank 1
Veteran
Dave asked on 29 Jun 2021, 04:25 PM

Hi,

Is there any way to get the mouse x,y of the dock as it's being dragged?   I have javascript examples that use dataTransfer, and have tried adapting them to dock events, OnClientDragStarted, OnClientDrag and OnClientDragEnd.   But OnClientDragStarted, which does provide access to the "OriginalEvent", does not have dataTransfer defined. And OnClientDrag provides no access to the "OriginalEvent".

Can you provide some direction?  Or is just not possible.

Dave

 

 

Dave
Top achievements
Rank 1
Veteran
commented on 29 Jun 2021, 08:23 PM

Turns out "OriginalEvent" is not needed. Instead, I used the following code to put the dock's x,y in its title. Seems to work. Can't use sender.get_left() or sender.get_top() while dragging, hence the getBoundClientRect().

Any issues with this approach?

function onDockDragStart(sender, args) {
var rect = sender.get_element().getBoundingClientRect();
var lsPosition = rect.left.toString() + ", " + rect.top.toString();
sender.set_title(lsPosition);
}
function onDockDrag(sender, args) {
var rect = sender.get_element().getBoundingClientRect();
var lsPosition = rect.left.toString() + ", " + rect.top.toString();
sender.set_title(lsPosition);
}
function onDockDragEnd(sender, args) {
var rect = sender.get_element().getBoundingClientRect();
var lsPosition = rect.left.toString() + ", " + rect.top.toString();
sender.set_title(lsPosition);
}
Vessy
Telerik team
commented on 02 Jul 2021, 11:34 AM

Hi Dave, the found by you approach is absolutely correct (you are not using any private members as well) and I do not see any problems with it.

No answers yet. Maybe you can help?

Tags
Dock
Asked by
Dave
Top achievements
Rank 1
Veteran
Share this question
or