-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
977 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/dockview-core/src/dnd/dropTargetAnchorContainer.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.dv-drop-target-container { | ||
position: absolute; | ||
z-index: 9999; | ||
top: 0px; | ||
left: 0px; | ||
height: 100%; | ||
width: 100%; | ||
pointer-events: none; | ||
overflow: hidden; | ||
--dv-transition-duration: 300ms; | ||
|
||
.dv-drop-target-anchor { | ||
position: relative; | ||
border: var(--dv-drag-over-border); | ||
transition: opacity var(--dv-transition-duration) ease-in, | ||
top var(--dv-transition-duration) ease-out, | ||
left var(--dv-transition-duration) ease-out, | ||
width var(--dv-transition-duration) ease-out, | ||
height var(--dv-transition-duration) ease-out; | ||
background-color: var(--dv-drag-over-background-color); | ||
opacity: 1; | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
packages/dockview-core/src/dnd/dropTargetAnchorContainer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { CompositeDisposable, Disposable } from '../lifecycle'; | ||
import { DropTargetTargetModel } from './droptarget'; | ||
|
||
export class DropTargetAnchorContainer extends CompositeDisposable { | ||
private _model: | ||
| { root: HTMLElement; overlay: HTMLElement; changed: boolean } | ||
| undefined; | ||
|
||
private _outline: HTMLElement | undefined; | ||
|
||
private _disabled = false; | ||
|
||
get disabled(): boolean { | ||
return this._disabled; | ||
} | ||
|
||
set disabled(value: boolean) { | ||
if (this.disabled === value) { | ||
return; | ||
} | ||
|
||
this._disabled = value; | ||
|
||
if (value) { | ||
this.model?.clear(); | ||
} | ||
} | ||
|
||
get model(): DropTargetTargetModel | undefined { | ||
if (this.disabled) { | ||
return undefined; | ||
} | ||
|
||
return { | ||
clear: () => { | ||
if (this._model) { | ||
this._model.root.parentElement?.removeChild( | ||
this._model.root | ||
); | ||
} | ||
this._model = undefined; | ||
}, | ||
exists: () => { | ||
return !!this._model; | ||
}, | ||
getElements: (event?: DragEvent, outline?: HTMLElement) => { | ||
const changed = this._outline !== outline; | ||
this._outline = outline; | ||
|
||
if (this._model) { | ||
this._model.changed = changed; | ||
return this._model; | ||
} | ||
|
||
const container = this.createContainer(); | ||
const anchor = this.createAnchor(); | ||
|
||
this._model = { root: container, overlay: anchor, changed }; | ||
|
||
container.appendChild(anchor); | ||
this.element.appendChild(container); | ||
|
||
if (event?.target instanceof HTMLElement) { | ||
const targetBox = event.target.getBoundingClientRect(); | ||
const box = this.element.getBoundingClientRect(); | ||
|
||
anchor.style.left = `${targetBox.left - box.left}px`; | ||
anchor.style.top = `${targetBox.top - box.top}px`; | ||
} | ||
|
||
return this._model; | ||
}, | ||
}; | ||
} | ||
|
||
constructor(readonly element: HTMLElement, options: { disabled: boolean }) { | ||
super(); | ||
|
||
this._disabled = options.disabled; | ||
|
||
this.addDisposables( | ||
Disposable.from(() => { | ||
this.model?.clear(); | ||
}) | ||
); | ||
} | ||
|
||
private createContainer(): HTMLElement { | ||
const el = document.createElement('div'); | ||
el.className = 'dv-drop-target-container'; | ||
|
||
return el; | ||
} | ||
|
||
private createAnchor(): HTMLElement { | ||
const el = document.createElement('div'); | ||
el.className = 'dv-drop-target-anchor'; | ||
el.style.visibility = 'hidden'; | ||
|
||
return el; | ||
} | ||
} |
Oops, something went wrong.