Constrained Drag and Drop

I’ve seen a few questions about how to restrict drag and drop so you can’t just drag something anywhere. I had some spare cycles so I put this together. There are probably several ways to do this, but I chose to delay the mouseMove handler to run after the DragManager has done its work, and reposition the dragImage and cursor in the mouseMove handler.
Download Source
Run Demo
You should be able to create variants that only allow vertical movement or don’t allow the dragImage outside of a certain rectangle.
Usual caveats apply. And yes, it isn’t a real game and doesn’t handle overlaying tiles.

2 Responses to Constrained Drag and Drop

  1. Russ Back says:

    Nice one Alex.
    I had a need recently to restrict drag and drop between two AdvancedDataGrids and came up with the below. Be interested to hear your thoughts.

  2. Francisc says:

    Very nice, Alex!