提交 94d91f81 编写于 作者: E Eugene Pankov

reset split ratio on double click (fixes #1377)

上级 e4f32c9a
......@@ -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}%`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册