Hi
on click of element i got a coordinates of element. but after dragging element on canvas getting same coordinates as first click.
how i can see updated coordinates or how i can update it?
i.e :
on first click coordinates are 260 - 80. after drag element still same coordinate.
how i can see updated coordinates or how i can update it?
Hey,
Could you please demonstrate with a little piece of code that how you get the coordinates of given shape, so that I can have a look at it and help you.
for a clicked element x and mouse cursor coordinates
let startx = $event.element.x;
let currentx = $event.originalEvent.layerX;
and where does the $event
come from?
on click event listener…
import * as viewer from 'bpmn-js/dist/bpmn-navigated-viewer.development.js';
// some code
const eventBus = this.viewer.get('eventBus');
if (eventBus) {
eventBus.on('element.click', ($event) => {
// some code
let startx = $event.element.x;
let currentx = $event.originalEvent.layerX;
// some code
}
Could you try listening for drag.move
or drag.eneded
events to see updated coordinates.
Please check here for the documentation.
I tried to listen drag event but its not fired on any drag. can you please suggest way to find it.
Here you go:
eventBus.on('drag.move', function(event){
// event has dx and dy fields
// event.context.elements has the shapes being dragged
});
when i run a BPMN diagram then it is in view mode.
i am able to listen only click event. drag.move isn’t fired.
If you are not modelling you won’t be able to drag things. You’ll only be able to view diagrams. What exactly are you trying to achieve?