Skip to content

Dragging overlapping sprites #378

@nimeratus

Description

@nimeratus

https://scratch.mit.edu/discuss/topic/847056/

Expected Behavior

The topmost sprite is picked up

Actual Behavior

Depending on the dragging speed, different things can happen:

  • the wrong sprite is picked up
  • the right sprite is picked up, but the other sprite is hidden and it's motion blocks are disabled

Steps to Reproduce

Place two sprites such that they are overlapping and the first sprite from the sprite list is on top of the second sprite. Try dragging the first sprite where it covers the second sprite.

If you click and wait until the sprite is automatically picked up, then it usually picks up the second sprite.
If you press the mouse button while the mouse is already moving then it usually hides the second sprite and picks up the first one

Steps to reproduce the behavior:

  1. Go to 'https://scratch.mit.edu/projects/editor/'
  2. Add a sprite (eg. 'Bear')
  3. Drag and drop the Scratch Cat on the Bear
  4. Try dragging the Scratch Cat where it covers the Bear

System Details

Windows 10, Chrome 132

Screenshots

scratchbug.webm

I've looked into the code and in https://github.com/scratchfoundation/scratch-editor/blob/develop/packages/scratch-gui/src/containers/stage.jsx#L345-L364 the draggable targets are listed in the order they appear in vm.runtime.targets, but this is not the layer order because it isn't changed by target.goToFront() because it uses moveExecutable() which only changes the order of executableTargets but not targets
But executableTargets also aren't always in the layer order, because when there is a speech bubble between two sprites and the sprite is moved forward then it only goes in front of the speech bubble but the execution order changes as if it moved in front of the other sprite https://scratch.mit.edu/projects/1239560616/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions