code-dot-org/blockly-core — pull request #65 by Bjvanminnen (2014-04-16 17:50:51+00:00)
Title: [Finishes #69582546] update position of all dragged blocks when looking for connections

set up a block relationship A->B->C. drag B (and with it C) and as if you’re trying to attach the bottom of B to the top of A. You see a notch highlight, but the highlight doesn't directly match up with any notches. It turns out the code is trying to highlight that you can attach the bottom of C to the top of B. If you drop the drag to attach, we throw an exception and the page becomes unresponsive. Strangely this doesn't repro if B->C didn't start out attached to A.

Turns out there's some really ugly code in Blockly.Connection.prototype.closest that is not easy to read/understand. It looks for the closest valid connection to a block, using cached x/y positions. For the dragged block, it makes sure to account for a delta from the cached position. This change makes it so that we also account for that delta for children of the main block that are also being dragged.