diff --git a/src/lib/elements/controls/SelectGroupElement.ts b/src/lib/elements/controls/SelectGroupElement.ts index ce00adb5c9d7486dfa8d28141373666d9622df89..c146316c4597155f20efe4e2a716f1be58646264 100644 --- a/src/lib/elements/controls/SelectGroupElement.ts +++ b/src/lib/elements/controls/SelectGroupElement.ts @@ -597,6 +597,13 @@ export class SelectGroupElement extends BaseContainer<SelectGroupModel> { // Unset display objects this.displayObjects = []; + + // Emits + if (this._type === SelectGroupType.GROUPING) { + this.getImage().emit("debouncedUnselectGrouping"); + } else { + this.getImage().emit("debouncedUnselectLayerGroup"); + } } //</editor-fold> diff --git a/src/lib/elements/images/Image.ts b/src/lib/elements/images/Image.ts index 00cf7f37960d1c613463d7821854c12b774ebef6..a41e36eaad3a3769e27b8c5034f0d6f0ceae9c20 100644 --- a/src/lib/elements/images/Image.ts +++ b/src/lib/elements/images/Image.ts @@ -81,8 +81,8 @@ export class Image extends BaseContainer<ImageModel> { */ // protected _debounceOnResizeMethod: EventListener; // protected _debounceImageZoomMethod: EventListener; - protected _debounceUndelectLayerGroupMethod: EventListener; - protected _debounceUndelectGroupingMethod: EventListener; + protected _debounceUnselectLayerGroupMethod: EventListener; + protected _debounceUnselectGroupingMethod: EventListener; protected _wheelMethod: EventListener; /** @@ -194,8 +194,8 @@ export class Image extends BaseContainer<ImageModel> { //<editor-fold desc="Methods"> // this._debounceOnResizeMethod = debounce(this.onResize.bind(this), 10).bind(this); // this._debounceImageZoomMethod = debounce(this..bind(this), 10).bind(this); - this._debounceUndelectLayerGroupMethod = debounce(this.unselectLayerGroup.bind(this), 10).bind(this); - this._debounceUndelectGroupingMethod = debounce(this.unselectGrouping.bind(this), 10).bind(this); + this._debounceUnselectLayerGroupMethod = debounce(this.unselectLayerGroup.bind(this), 50).bind(this); + this._debounceUnselectGroupingMethod = debounce(this.unselectGrouping.bind(this), 50).bind(this); this._wheelMethod = this.zoomInteraction.onZoom.bind(this.zoomInteraction); //</editor-fold> @@ -210,8 +210,8 @@ export class Image extends BaseContainer<ImageModel> { parent.on("pointermove", this.moveInteraction.onMove, this.moveInteraction); parent.on("mouseup", this.moveInteraction.endMove, this.moveInteraction); // -- Debounce - this.on("debouncedUnselectLayerGroup", this._debounceUndelectLayerGroupMethod); - this.on("debouncedUnselectGrouping", this._debounceUndelectGroupingMethod); + this.on("debouncedUnselectLayerGroup", this._debounceUnselectLayerGroupMethod); + this.on("debouncedUnselectGrouping", this._debounceUnselectGroupingMethod); // -- Wheel this.canvas.addEventListener("wheel", this._wheelMethod); }); @@ -225,8 +225,8 @@ export class Image extends BaseContainer<ImageModel> { parent.off("pointermove", this.moveInteraction.onMove, this.moveInteraction); parent.off("mouseup", this.moveInteraction.endMove, this.moveInteraction); // -- Debounce - this.off("debouncedUnselectLayerGroup", this._debounceUndelectLayerGroupMethod); - this.off("debouncedUnselectGrouping", this._debounceUndelectGroupingMethod); + this.off("debouncedUnselectLayerGroup", this._debounceUnselectLayerGroupMethod); + this.off("debouncedUnselectGrouping", this._debounceUnselectGroupingMethod); // -- Wheel this.canvas.removeEventListener("wheel", this._wheelMethod); // TODO remove delete this._wheelMethod; @@ -1623,7 +1623,9 @@ export class Image extends BaseContainer<ImageModel> { * Unselect grouping */ public unselectGrouping(): void { - this.emit("unselectGrouping"); + if (!this._selectGroupElement.visible && !this._selectItemElement.visible) { + this.emit("unselectGrouping"); + } } //</editor-fold> @@ -1683,7 +1685,9 @@ export class Image extends BaseContainer<ImageModel> { * Unselect layer group */ public unselectLayerGroup(): void { - this.emit("unselectLayerGroup"); + if (!this._selectGroupElement.visible && !this._selectItemElement.visible) { + this.emit("unselectLayerGroup"); + } } /**