Skip to content

Fix dragging sprites#603

Open
nimeratus wants to merge 3 commits into
scratchfoundation:developfrom
nimeratus:fix-dragging-sprites
Open

Fix dragging sprites#603
nimeratus wants to merge 3 commits into
scratchfoundation:developfrom
nimeratus:fix-dragging-sprites

Conversation

@nimeratus

Copy link
Copy Markdown

Resolves

Proposed Changes

  • Remove the data about which sprite is dragged from the <Stage>'s React state and put it in its JavaScript properties
  • Sort the candidate drawables into layer order in RenderWebGL.pick()

Reason for Changes

  • Prevents the situation where it starts dragging a sprite but then the info that it's already dragging something doesn't update before it gets a second mouse event, and so it starts dragging another sprite but doesn't tell the first one that it isn't being dragged anymore
  • Makes sure that the topmost sprite is picked up when dragging

Test Coverage

I've exported player.html and player.js and imported this project into it and tried to reproduce the bugs and they didn't happen

puts the info about dragging into JavaScript properties,
instead of putting it in the React state

this fixes a bug that put the sprites into an invalid state if multiple
mouse events arrived before the drag info got updated
fixes the bug where sometimes not the topmost draggable sprite
was picked up when dragging
@nimeratus nimeratus requested a review from a team as a code owner June 5, 2026 15:22
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@nimeratus

Copy link
Copy Markdown
Author

I have read the CLA Document and there was no "not" before the "infringe".
This way that sentence means things like "You warrant that the Contribution will infringe upon the rights of any third party."

@rosics-code rosics-code left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good!

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.

Bug when dragging overlapping sprites

2 participants