mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-21 20:52:12 -03:00
fixed the persistent shape preview bug
fixed the persistent shape preview bug where blue dashed lines would remain visible even when the user was no longer interacting with the slider. The issue was caused by race conditions and timing problems in the preview system.
This commit is contained in:
@@ -113,6 +113,9 @@ export class CustomShapeMenu {
|
||||
const checkboxContainer = this._createCheckbox(
|
||||
() => `${this.canvas.autoApplyShapeMask ? "☑" : "☐"} Auto-apply shape mask`,
|
||||
() => {
|
||||
// Always hide any active shape preview lines first to prevent them from getting stuck
|
||||
this.canvas.maskTool.hideShapePreview();
|
||||
|
||||
this.canvas.autoApplyShapeMask = !this.canvas.autoApplyShapeMask;
|
||||
|
||||
if (this.canvas.autoApplyShapeMask) {
|
||||
@@ -140,6 +143,7 @@ export class CustomShapeMenu {
|
||||
this._updateUI();
|
||||
|
||||
if (this.canvas.autoApplyShapeMask) {
|
||||
this.canvas.maskTool.hideShapePreview();
|
||||
this.canvas.maskTool.applyShapeMask();
|
||||
this.canvas.render();
|
||||
}
|
||||
@@ -252,6 +256,7 @@ export class CustomShapeMenu {
|
||||
this._updateUI();
|
||||
|
||||
if (this.canvas.autoApplyShapeMask) {
|
||||
this.canvas.maskTool.hideShapePreview();
|
||||
this.canvas.maskTool.applyShapeMask();
|
||||
this.canvas.render();
|
||||
}
|
||||
|
||||
@@ -1265,11 +1265,20 @@ export class MaskTool {
|
||||
* Hide shape preview and switch back to normal mode
|
||||
*/
|
||||
hideShapePreview(): void {
|
||||
// Cancel any pending throttled preview updates to prevent race conditions
|
||||
if (this.shapePreviewThrottleTimeout !== null) {
|
||||
clearTimeout(this.shapePreviewThrottleTimeout);
|
||||
this.shapePreviewThrottleTimeout = null;
|
||||
}
|
||||
|
||||
// Clear any pending preview parameters
|
||||
this.pendingPreviewParams = null;
|
||||
|
||||
this.isPreviewMode = false;
|
||||
this.shapePreviewVisible = false;
|
||||
this.clearShapePreview();
|
||||
this.shapePreviewCanvas.style.display = 'none';
|
||||
log.debug("Shape preview hidden");
|
||||
log.debug("Shape preview hidden and all pending operations cancelled");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user