Skip to content

Commit 71ca797

Browse files
authored
feat: Add a sound effect when dropping top-level items on the workspace (#9784)
1 parent 9a01417 commit 71ca797

4 files changed

Lines changed: 6 additions & 0 deletions

File tree

packages/blockly/core/dragging/block_drag_strategy.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,10 @@ export class BlockDragStrategy implements IDragStrategy {
786786
this.applyConnections(this.connectionCandidate);
787787
this.disposeStep();
788788
} else {
789+
// play a sound if the block didn't connect to anything and isn't being deleted
790+
if (disposition !== DragDisposition.DELETE) {
791+
this.workspace.getAudioManager().play('drop');
792+
}
789793
this.block.queueRender().then(() => this.disposeStep());
790794
}
791795

packages/blockly/core/dragging/comment_drag_strategy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class CommentDragStrategy implements IDragStrategy {
5050
this.workspace
5151
.getLayerManager()
5252
?.moveOffDragLayer(this.comment, layers.BLOCK);
53+
this.workspace.getAudioManager().play('drop');
5354
this.comment.setDragging(false);
5455

5556
this.comment.snapToGrid();

packages/blockly/core/inject.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,4 +333,5 @@ function loadSounds(pathToMedia: string, workspace: WorkspaceSvg) {
333333
audioMgr.load([`${pathToMedia}click.mp3`], 'click');
334334
audioMgr.load([`${pathToMedia}disconnect.mp3`], 'disconnect');
335335
audioMgr.load([`${pathToMedia}delete.mp3`], 'delete');
336+
audioMgr.load([`${pathToMedia}drop.mp3`], 'drop');
336337
}

packages/blockly/media/drop.mp3

5.31 KB
Binary file not shown.

0 commit comments

Comments
 (0)