diff --git a/terminus-core/src/components/splitTabSpanner.component.ts b/terminus-core/src/components/splitTabSpanner.component.ts index e0fb7805..e06ce5d4 100644 --- a/terminus-core/src/components/splitTabSpanner.component.ts +++ b/terminus-core/src/components/splitTabSpanner.component.ts @@ -23,6 +23,10 @@ export class SplitTabSpannerComponent { constructor (private element: ElementRef) { } ngAfterViewInit () { + this.element.nativeElement.addEventListener('dblclick', () => { + this.reset() + }) + this.element.nativeElement.addEventListener('mousedown', (e: MouseEvent) => { this.isActive = true const start = this.isVertical ? e.pageY : e.pageX @@ -49,14 +53,16 @@ export class SplitTabSpannerComponent { diff = Math.max(diff, -this.container.ratios[this.index - 1] + 0.1) diff = Math.min(diff, this.container.ratios[this.index] - 0.1) - this.container.ratios[this.index - 1] += diff - this.container.ratios[this.index] -= diff - this.change.emit() + if (diff) { + this.container.ratios[this.index - 1] += diff + this.container.ratios[this.index] -= diff + this.change.emit() + } } - document.addEventListener('mouseup', offHandler) + document.addEventListener('mouseup', offHandler, { passive: true }) this.element.nativeElement.parentElement.addEventListener('mousemove', dragHandler) - }) + }, { passive: true }) } ngOnChanges () { @@ -79,6 +85,13 @@ export class SplitTabSpannerComponent { } } + reset () { + const ratio = (this.container.ratios[this.index - 1] + this.container.ratios[this.index]) / 2 + this.container.ratios[this.index - 1] = ratio + this.container.ratios[this.index] = ratio + this.change.emit() + } + private setDimensions (x: number, y: number, w: number, h: number) { this.cssLeft = `${x}%` this.cssTop = `${y}%`