mirror of
https://github.com/Eugeny/tabby
synced 2024-11-14 17:07:15 +00:00
fixed tab rearranging conditions
This commit is contained in:
parent
c736a84835
commit
f27e1ec62d
1 changed files with 13 additions and 2 deletions
|
@ -4,6 +4,7 @@ import { AppService } from '../services/app.service'
|
|||
import { BaseTabComponent } from './baseTab.component'
|
||||
import { SelfPositioningComponent } from './selfPositioning.component'
|
||||
import { SplitDropZoneInfo } from './splitTab.component'
|
||||
import { SplitTabComponent } from './splitTab.component'
|
||||
|
||||
/** @hidden */
|
||||
@Component({
|
||||
|
@ -22,7 +23,7 @@ import { SplitDropZoneInfo } from './splitTab.component'
|
|||
})
|
||||
export class SplitTabDropZoneComponent extends SelfPositioningComponent {
|
||||
@Input() dropZone: SplitDropZoneInfo
|
||||
@Input() parent: BaseTabComponent
|
||||
@Input() parent: SplitTabComponent
|
||||
@Output() tabDropped = new EventEmitter<BaseTabComponent>()
|
||||
@HostBinding('class.active') isActive = false
|
||||
@HostBinding('class.highlighted') isHighlighted = false
|
||||
|
@ -34,11 +35,21 @@ export class SplitTabDropZoneComponent extends SelfPositioningComponent {
|
|||
) {
|
||||
super(element)
|
||||
this.subscribeUntilDestroyed(app.tabDragActive$, tab => {
|
||||
this.isActive = !!tab && tab !== this.parent && (this.dropZone.type === 'relative' || tab !== this.dropZone.container.children[this.dropZone.position])
|
||||
this.isActive = !!tab && this.canActivateFor(tab)
|
||||
this.layout()
|
||||
})
|
||||
}
|
||||
|
||||
canActivateFor (tab: BaseTabComponent): boolean {
|
||||
const allTabs = this.parent.getAllTabs()
|
||||
return !(
|
||||
tab === this.parent ||
|
||||
allTabs.length === 1 && allTabs.includes(tab) ||
|
||||
this.dropZone.type === 'relative' && tab === this.dropZone.relativeTo ||
|
||||
this.dropZone.type === 'absolute' && tab === this.dropZone.container.children[this.dropZone.position]
|
||||
)
|
||||
}
|
||||
|
||||
ngOnChanges () {
|
||||
this.layout()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue