mirror of
https://github.com/Eugeny/tabby
synced 2024-11-15 09:27:24 +00:00
reset split ratio on double click (fixes #1377)
This commit is contained in:
parent
e4f32c9ade
commit
94d91f8182
1 changed files with 18 additions and 5 deletions
|
@ -23,6 +23,10 @@ export class SplitTabSpannerComponent {
|
||||||
constructor (private element: ElementRef) { }
|
constructor (private element: ElementRef) { }
|
||||||
|
|
||||||
ngAfterViewInit () {
|
ngAfterViewInit () {
|
||||||
|
this.element.nativeElement.addEventListener('dblclick', () => {
|
||||||
|
this.reset()
|
||||||
|
})
|
||||||
|
|
||||||
this.element.nativeElement.addEventListener('mousedown', (e: MouseEvent) => {
|
this.element.nativeElement.addEventListener('mousedown', (e: MouseEvent) => {
|
||||||
this.isActive = true
|
this.isActive = true
|
||||||
const start = this.isVertical ? e.pageY : e.pageX
|
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.max(diff, -this.container.ratios[this.index - 1] + 0.1)
|
||||||
diff = Math.min(diff, this.container.ratios[this.index] - 0.1)
|
diff = Math.min(diff, this.container.ratios[this.index] - 0.1)
|
||||||
|
|
||||||
this.container.ratios[this.index - 1] += diff
|
if (diff) {
|
||||||
this.container.ratios[this.index] -= diff
|
this.container.ratios[this.index - 1] += diff
|
||||||
this.change.emit()
|
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)
|
this.element.nativeElement.parentElement.addEventListener('mousemove', dragHandler)
|
||||||
})
|
}, { passive: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges () {
|
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) {
|
private setDimensions (x: number, y: number, w: number, h: number) {
|
||||||
this.cssLeft = `${x}%`
|
this.cssLeft = `${x}%`
|
||||||
this.cssTop = `${y}%`
|
this.cssTop = `${y}%`
|
||||||
|
|
Loading…
Reference in a new issue