Cache delete area rectangle bounds in the on mouse down event#247
Cache delete area rectangle bounds in the on mouse down event#247NeilFraser merged 1 commit intoRaspberryPiFoundation:2016from
Conversation
to avoid getting it for every mouse move event. The delete areas won't change while the user is dragging blocks around. Also switch calculations for delete area inclusion to be done in client coordinates so we don't have to convert to svg coordinates on every mouse move event. This should speed up dragging blocks a bunch.
| * @private | ||
| */ | ||
| Blockly.Trashcan.prototype.MARGIN_HOTSPOT_ = 25; | ||
| Blockly.Trashcan.prototype.MARGIN_HOTSPOT_ = 10; |
There was a problem hiding this comment.
Is this a UI change? We increased the hotspot as a result of seeing frustrated children accumulate a bunch of badly-aimed blocks around the trash.
Otherwise, this PR looks great! Thanks for not scolding me about BIG_NUM; not my proudest code.
There was a problem hiding this comment.
It does have a small impact, though less than not changing it at all.
The bounding box calculations are different now and come out slightly larger, mostly in the height. My theory is it was using a fixed height before that may not have included the space between the lid and the trash and a potential margin. I spent some time trying to draw some boundaries in css to verify, but so far have failed.
Changing it to 10 keeps the behavior roughly the same when coming towards the trash can from the top/bottom and makes it slightly harder (about the width of the letter 'o') when coming in from the left/right.
I thought it was close enough, but if it has been a sticking point in the past and you want me to get to the true bottom of it and match the old behavior exactly, let me know!
Cache delete area rectangle bounds in the on mouse down event
to avoid getting it for every mouse move event. The delete areas
won't change while the user is dragging blocks around.
Also switch calculations for delete area inclusion to be done in
client coordinates so we don't have to convert to svg coordinates on
every mouse move event.
This should speed up dragging blocks a bunch.