mirror of
https://github.com/mathuo/dockview
synced 2025-08-30 14:06:22 +00:00
feat: use native event defaulting
This commit is contained in:
parent
fd2460416a
commit
063bd4adf1
@ -1,5 +1,5 @@
|
|||||||
import { toggleClass } from '../dom';
|
import { toggleClass } from '../dom';
|
||||||
import { DockviewEvent, Emitter, Event } from '../events';
|
import { Emitter, Event } from '../events';
|
||||||
import { CompositeDisposable } from '../lifecycle';
|
import { CompositeDisposable } from '../lifecycle';
|
||||||
import { DragAndDropObserver } from './dnd';
|
import { DragAndDropObserver } from './dnd';
|
||||||
import { clamp } from '../math';
|
import { clamp } from '../math';
|
||||||
@ -10,26 +10,9 @@ export interface DroptargetEvent {
|
|||||||
readonly nativeEvent: DragEvent;
|
readonly nativeEvent: DragEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WillShowOverlayEvent
|
export interface WillShowOverlayEvent extends DroptargetEvent {
|
||||||
extends DockviewEvent
|
readonly nativeEvent: DragEvent;
|
||||||
implements DroptargetEvent
|
readonly position: Position;
|
||||||
{
|
|
||||||
get nativeEvent(): DragEvent {
|
|
||||||
return this.options.nativeEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
get position(): Position {
|
|
||||||
return this.options.position;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private readonly options: {
|
|
||||||
nativeEvent: DragEvent;
|
|
||||||
position: Position;
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function directionToPosition(direction: Direction): Position {
|
export function directionToPosition(direction: Direction): Position {
|
||||||
@ -170,10 +153,10 @@ export class Droptarget extends CompositeDisposable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const willShowOverlayEvent = new WillShowOverlayEvent({
|
const willShowOverlayEvent: WillShowOverlayEvent = {
|
||||||
nativeEvent: e,
|
nativeEvent: e,
|
||||||
position: quadrant,
|
position: quadrant,
|
||||||
});
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide an opportunity to prevent the overlay appearing and in turn
|
* Provide an opportunity to prevent the overlay appearing and in turn
|
||||||
@ -181,7 +164,7 @@ export class Droptarget extends CompositeDisposable {
|
|||||||
*/
|
*/
|
||||||
this._onWillShowOverlay.fire(willShowOverlayEvent);
|
this._onWillShowOverlay.fire(willShowOverlayEvent);
|
||||||
|
|
||||||
if (willShowOverlayEvent.defaultPrevented) {
|
if (willShowOverlayEvent.nativeEvent.defaultPrevented) {
|
||||||
this.removeDropTarget();
|
this.removeDropTarget();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2134,7 +2134,7 @@ export class DockviewComponent
|
|||||||
}),
|
}),
|
||||||
view.model.onWillShowOverlay((event) => {
|
view.model.onWillShowOverlay((event) => {
|
||||||
if (this.options.disableDnd) {
|
if (this.options.disableDnd) {
|
||||||
event.event.preventDefault();
|
event.event.nativeEvent.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user