don't show drop hints when dragging the tab onto itself

This commit is contained in:
Eugene Pankov 2021-07-27 20:27:03 +02:00
parent 90e56e7605
commit 85fe9eb4ec
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4
2 changed files with 10 additions and 3 deletions

View file

@ -147,6 +147,7 @@ export interface SplitDropZoneInfo {
></split-tab-spanner>
<split-tab-drop-zone
*ngFor='let dropZone of _dropZones'
[parent]='this'
[dropZone]='dropZone'
(tabDropped)='onTabDropped($event, dropZone)'
>

View file

@ -22,6 +22,7 @@ import { SplitDropZoneInfo } from './splitTab.component'
})
export class SplitTabDropZoneComponent extends SelfPositioningComponent {
@Input() dropZone: SplitDropZoneInfo
@Input() parent: BaseTabComponent
@Output() tabDropped = new EventEmitter<BaseTabComponent>()
@HostBinding('class.active') isActive = false
@HostBinding('class.highlighted') isHighlighted = false
@ -32,8 +33,8 @@ export class SplitTabDropZoneComponent extends SelfPositioningComponent {
app: AppService,
) {
super(element)
this.subscribeUntilDestroyed(app.tabDragActive$, active => {
this.isActive = active
this.subscribeUntilDestroyed(app.tabDragActive$, tab => {
this.isActive = !!tab && tab !== this.parent
this.layout()
})
}
@ -43,7 +44,12 @@ export class SplitTabDropZoneComponent extends SelfPositioningComponent {
}
layout () {
const tabElement: HTMLElement = this.dropZone.relativeToTab.viewContainerEmbeddedRef?.rootNodes[0]
const tabElement: HTMLElement|undefined = this.dropZone.relativeToTab.viewContainerEmbeddedRef?.rootNodes[0]
if (!tabElement) {
// being destroyed
return
}
const args = {
t: [0, 0, tabElement.clientWidth, tabElement.clientHeight / 5],