Skip to content

Commit b6db9fe

Browse files
committed
feat: Add IPathObject.updateReplacing()
1 parent 7f4ec3a commit b6db9fe

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

core/block_svg.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,11 +1735,7 @@ export class BlockSvg
17351735
* @internal
17361736
*/
17371737
fadeForReplacement(add: boolean) {
1738-
if (add) {
1739-
this.addClass('blocklyReplaceable');
1740-
} else {
1741-
this.removeClass('blocklyReplaceable');
1742-
}
1738+
this.pathObject.updateReplacing?.(add);
17431739
}
17441740

17451741
/**

core/renderers/common/i_path_object.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,13 @@ export interface IPathObject {
106106
* @param blockStyle The block style to use.
107107
*/
108108
setStyle?(blockStyle: BlockStyle): void;
109+
110+
/**
111+
* Add or remove styling indicating that a block will be bumped out and
112+
* replaced by another block that is mid-move.
113+
*
114+
* @param replacing True if the block is at risk of being replaced, false
115+
* otherwise.
116+
*/
117+
updateReplacing?(replacing: boolean): void;
109118
}

core/renderers/common/path_object.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,17 @@ export class PathObject implements IPathObject {
191191
this.setClass_('blocklyDraggable', enable);
192192
}
193193

194+
/**
195+
* Add or remove styling indicating that a block will be bumped out and
196+
* replaced by another block that is mid-move.
197+
*
198+
* @param replacing True if the block is at risk of being replaced, false
199+
* otherwise.
200+
*/
201+
updateReplacing(replacing: boolean) {
202+
this.setClass_('blocklyReplaceable', replacing);
203+
}
204+
194205
/** Adds the given path as a connection highlight for the given connection. */
195206
addConnectionHighlight(
196207
connection: RenderedConnection,

0 commit comments

Comments
 (0)