Detect when a block stop to be dragged

350 Views Asked by At

I'd like to trigger a function when the user stop to drag blocks around. But it seems blockly only support block creation/deletion/moving & change event detection, is there a way to do that?

1

There are 1 best solutions below

0
On

I'm pretty sure Blockly.Events.BLOCK_MOVE is only called after the block is moved.

You can also detect if (https://developers.google.com/blockly/guides/configure/web/events#blocklyeventsblock_drag) and if the mouse is down, then wait for the mouse to be up.

Here is some example code:

JS

mouseState="up"
onBlockDrag(){ //youll need to setup the onblockdrag event
mouseState="down"
while (mouseState = "down"){
//do nothing while mouse down
}
//after mouse down
// your code
}

HTML

<div id="blocklyDiv" ng-mouseup="mouseState='up'"></div>