diff --git a/core/block_svg.ts b/core/block_svg.ts index 269081a6e..231af949d 100644 --- a/core/block_svg.ts +++ b/core/block_svg.ts @@ -1735,11 +1735,7 @@ export class BlockSvg * @internal */ fadeForReplacement(add: boolean) { - if (add) { - this.addClass('blocklyReplaceable'); - } else { - this.removeClass('blocklyReplaceable'); - } + this.pathObject.updateReplacing?.(add); } /** diff --git a/core/renderers/common/i_path_object.ts b/core/renderers/common/i_path_object.ts index a68c3a411..a7379bbea 100644 --- a/core/renderers/common/i_path_object.ts +++ b/core/renderers/common/i_path_object.ts @@ -106,4 +106,13 @@ export interface IPathObject { * @param blockStyle The block style to use. */ setStyle?(blockStyle: BlockStyle): void; + + /** + * Add or remove styling indicating that a block will be bumped out and + * replaced by another block that is mid-move. + * + * @param replacing True if the block is at risk of being replaced, false + * otherwise. + */ + updateReplacing?(replacing: boolean): void; } diff --git a/core/renderers/common/path_object.ts b/core/renderers/common/path_object.ts index 50ea9252d..e6cb4962f 100644 --- a/core/renderers/common/path_object.ts +++ b/core/renderers/common/path_object.ts @@ -191,6 +191,17 @@ export class PathObject implements IPathObject { this.setClass_('blocklyDraggable', enable); } + /** + * Add or remove styling indicating that a block will be bumped out and + * replaced by another block that is mid-move. + * + * @param replacing True if the block is at risk of being replaced, false + * otherwise. + */ + updateReplacing(replacing: boolean) { + this.setClass_('blocklyReplaceable', replacing); + } + /** Adds the given path as a connection highlight for the given connection. */ addConnectionHighlight( connection: RenderedConnection,