mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-04 22:14:55 +00:00
.
This commit is contained in:
@@ -40,7 +40,7 @@ import { AppService, IToolbarButton, ToolbarButtonProvider } from '../api'
|
||||
})
|
||||
export class AppRootComponent {
|
||||
toasterConfig: ToasterConfig
|
||||
logger: Logger
|
||||
private logger: Logger
|
||||
|
||||
constructor(
|
||||
private docking: DockingService,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { BehaviorSubject } from 'rxjs'
|
||||
import { EventEmitter, ViewRef } from '@angular/core'
|
||||
import { Subject, BehaviorSubject } from 'rxjs'
|
||||
import { ViewRef } from '@angular/core'
|
||||
|
||||
|
||||
export abstract class BaseTabComponent {
|
||||
@@ -7,13 +7,20 @@ export abstract class BaseTabComponent {
|
||||
title$ = new BehaviorSubject<string>(null)
|
||||
scrollable: boolean
|
||||
hasActivity = false
|
||||
focused = new EventEmitter<any>()
|
||||
blurred = new EventEmitter<any>()
|
||||
focused$ = new Subject<void>()
|
||||
blurred$ = new Subject<void>()
|
||||
hasFocus = false
|
||||
hostView: ViewRef
|
||||
private static lastTabID = 0
|
||||
|
||||
constructor () {
|
||||
this.id = BaseTabComponent.lastTabID++
|
||||
this.focused$.subscribe(() => {
|
||||
this.hasFocus = true
|
||||
})
|
||||
this.blurred$.subscribe(() => {
|
||||
this.hasFocus = false
|
||||
})
|
||||
}
|
||||
|
||||
displayActivity (): void {
|
||||
@@ -25,5 +32,8 @@ export abstract class BaseTabComponent {
|
||||
}
|
||||
|
||||
destroy (): void {
|
||||
this.focused$.complete()
|
||||
this.blurred$.complete()
|
||||
this.title$.complete()
|
||||
}
|
||||
}
|
||||
|
@@ -4,9 +4,10 @@ import { BaseTabComponent } from '../components/baseTab.component'
|
||||
@Component({
|
||||
selector: 'tab-body',
|
||||
template: `
|
||||
<perfect-scrollbar [config]="{ suppressScrollX: true, suppressScrollY: !scrollable}">
|
||||
<ng-template #placeholder></ng-template>
|
||||
<perfect-scrollbar [config]="{ suppressScrollX: true }" *ngIf="scrollable">
|
||||
<ng-template #scrollablePlaceholder></ng-template>
|
||||
</perfect-scrollbar>
|
||||
<template #nonScrollablePlaceholder [ngIf]="!scrollable"></template>
|
||||
`,
|
||||
styles: [
|
||||
require('./tabBody.component.scss'),
|
||||
@@ -17,11 +18,12 @@ export class TabBodyComponent {
|
||||
@Input() @HostBinding('class.active') active: boolean
|
||||
@Input() tab: BaseTabComponent
|
||||
@Input() scrollable: boolean
|
||||
@ViewChild('placeholder', {read: ViewContainerRef}) placeholder: ViewContainerRef
|
||||
@ViewChild('scrollablePlaceholder', {read: ViewContainerRef}) scrollablePlaceholder: ViewContainerRef
|
||||
@ViewChild('nonScrollablePlaceholder', {read: ViewContainerRef}) nonScrollablePlaceholder: ViewContainerRef
|
||||
|
||||
ngAfterViewInit () {
|
||||
setImmediate(() => {
|
||||
this.placeholder.insert(this.tab.hostView)
|
||||
(this.scrollable ? this.scrollablePlaceholder : this.nonScrollablePlaceholder).insert(this.tab.hostView)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -51,11 +51,11 @@ export class AppService {
|
||||
}
|
||||
if (this.activeTab) {
|
||||
this.activeTab.hasActivity = false
|
||||
this.activeTab.blurred.emit()
|
||||
this.activeTab.blurred$.next()
|
||||
}
|
||||
this.activeTab = tab
|
||||
if (this.activeTab) {
|
||||
this.activeTab.focused.emit()
|
||||
this.activeTab.focused$.next()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user