flowy icon indicating copy to clipboard operation
flowy copied to clipboard

OnSnap trigger

Open pilootchoum opened this issue 4 years ago • 3 comments

Is the OnSnap function only triggered when droping a block from outside the canvas? It seems the function is not triggered when moving some blocks inside the canvas,

Is there any way to catch this event?

pilootchoum avatar Apr 24 '20 15:04 pilootchoum

That is currently how it works, yes. The problem is that the OnSnap method allows the developer to return false to prevent a block from attaching, which in the case of being dragged from outside, means it is deleted.

Were it also triggering when rearranging, I'm not sure what the default behaviour should be. Deleting the blocks? Snapping to the previous parent?

alyssaxuu avatar Apr 24 '20 15:04 alyssaxuu

Yes I guess in the OnRearrrange method, I guess we should be able to make a choice.

Either delete the blocks, or attach to the new parent, or snap back to the previous parent.

Because the problem is, let say you are implementing some functional restrictions in the onSnap functions. So prevent one block of type A to snap on a block of type B. Then that could be overriden once the blocks are on the canvas and reaarranging after that.

pilootchoum avatar Apr 24 '20 15:04 pilootchoum

Yes I guess in the OnRearrrange method, I guess we should be able to make a choice.

Either delete the blocks, or attach to the new parent, or snap back to the previous parent.

Because the problem is, let say you are implementing some functional restrictions in the onSnap functions. So prevent one block of type A to snap on a block of type B. Then that could be overriden once the blocks are on the canvas and reaarranging after that.

Hmm, all right.

I suppose I could also give the option of showing the indicator blue pulse under the block when in proximity to be more user intuitive? That way it would make sense if a block was dragged there and was deleted/repositioned. I could implement that functionality for the current OnSnap method with the outside blocks as well.

I think it's a good idea, although I will be releasing it together with multiple other improvements & features, so it isn't going to be implemented right now. Adding it to the milestone.

alyssaxuu avatar Apr 24 '20 15:04 alyssaxuu