Draw2d on drag start event

I want to call my callback function every time when the user starts dragging numbers. I tried to do it like this:

figure.onDragStart = function (x, y, shiftKey, ctrlKey) {
    myfunc();
};

But the problem is that every time my function is called, the figure is positioned at 0,0 coordinates. I am not sure what is wrong with this, and how I can fix it.

+4
source share
1 answer

Instead of overriding the method, onDragStartyou can handle the event dragstart:

figure.on("dragstart", function(event, ui) {
    // Do something
});

According to draw2d documentation , this event is fired onDragStart. Parameter uicontains x, y, shiftKeyand ctrlKey.

jsfiddle. , . dragstart . onDragStart , .

+3

Source: https://habr.com/ru/post/1683754/


All Articles