Skip to content

Commit

Permalink
refactor: Add addClass and removeClass methods to blockSvg (#8337)
Browse files Browse the repository at this point in the history
* refactor: Add `addClass` and `removeClass` methods to blockSvg

* fix: lint

* fix: jsdoc
  • Loading branch information
ishon19 authored Jul 15, 2024
1 parent 9684942 commit 7c22c46
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions core/block_svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,24 @@ export class BlockSvg
}
}

/**
* Add a CSS class to the SVG group of this block.
*
* @param className
*/
addClass(className: string) {
dom.addClass(this.svgGroup_, className);
}

/**
* Remove a CSS class from the SVG group of this block.
*
* @param className
*/
removeClass(className: string) {
dom.removeClass(this.svgGroup_, className);
}

/**
* Recursively adds or removes the dragging class to this node and its
* children.
Expand All @@ -683,10 +701,10 @@ export class BlockSvg
if (adding) {
this.translation = '';
common.draggingConnections.push(...this.getConnections_(true));
dom.addClass(this.svgGroup_, 'blocklyDragging');
this.addClass('blocklyDragging');
} else {
common.draggingConnections.length = 0;
dom.removeClass(this.svgGroup_, 'blocklyDragging');
this.removeClass('blocklyDragging');
}
// Recurse through all blocks attached under this one.
for (let i = 0; i < this.childBlocks_.length; i++) {
Expand Down

0 comments on commit 7c22c46

Please sign in to comment.