refactor: Add addClass and removeClass methods to blockSvg (#8337)

* refactor: Add `addClass` and `removeClass` methods to blockSvg

* fix: lint

* fix: jsdoc
This commit is contained in:
Shreyans Pathak
2024-07-15 14:54:30 -04:00
committed by GitHub
parent 968494205a
commit 7c22c46ee6

View File

@@ -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.
@@ -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++) {