remove drop-target overlays when not needed

This commit is contained in:
mathuo 2023-07-05 20:23:30 +01:00
parent 47fb99a06f
commit c1bf5deaf9
No known key found for this signature in database
GPG Key ID: C6EEDEFD6CA07281

View File

@ -95,6 +95,11 @@ export class Droptarget extends CompositeDisposable {
new DragAndDropObserver(this.element, {
onDragEnter: () => undefined,
onDragOver: (e) => {
if (this._acceptedTargetZonesSet.size === 0) {
this.removeDropTarget();
return;
}
const width = this.element.clientWidth;
const height = this.element.clientHeight;
@ -129,9 +134,11 @@ export class Droptarget extends CompositeDisposable {
if (typeof this.options.canDisplayOverlay === 'boolean') {
if (!this.options.canDisplayOverlay) {
this.removeDropTarget();
return;
}
} else if (!this.options.canDisplayOverlay(e, quadrant)) {
this.removeDropTarget();
return;
}
@ -149,14 +156,6 @@ export class Droptarget extends CompositeDisposable {
this.element.append(this.targetElement);
}
if (this.options.acceptedTargetZones.length === 0) {
return;
}
if (!this.targetElement || !this.overlayElement) {
return;
}
this.toggleClasses(quadrant, width, height);
this.setState(quadrant);