Skip to content

Cache delete area rectangle bounds in the on mouse down event#247

Merged
NeilFraser merged 1 commit intoRaspberryPiFoundation:2016from
picklesrus:drag-perf
Feb 4, 2016
Merged

Cache delete area rectangle bounds in the on mouse down event#247
NeilFraser merged 1 commit intoRaspberryPiFoundation:2016from
picklesrus:drag-perf

Conversation

@picklesrus
Copy link
Copy Markdown
Contributor

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.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

NeilFraser added a commit that referenced this pull request Feb 4, 2016
Cache delete area rectangle bounds in the on mouse down event
@NeilFraser NeilFraser merged commit 3e6e962 into RaspberryPiFoundation:2016 Feb 4, 2016
@picklesrus picklesrus deleted the drag-perf branch April 12, 2016 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants