From b10619182e657a6afc4cbe5f94c1d4616cd04603 Mon Sep 17 00:00:00 2001 From: isakfredriksson Date: Mon, 4 Dec 2023 17:39:22 +0100 Subject: [PATCH] Minor tweaks to dropEndHandler, gonna reuse the end code for double click handler --- src/app/editor/editor.component.ts | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/app/editor/editor.component.ts b/src/app/editor/editor.component.ts index 13f9576..56f688b 100644 --- a/src/app/editor/editor.component.ts +++ b/src/app/editor/editor.component.ts @@ -122,18 +122,23 @@ export class EditorComponent implements OnInit { } dropEndHandler(event: CdkDragDrop | CdkDragDrop) { - let bounds = this.planElemFilterBounds(); - let end = this.plan.plan.length; - if (bounds) { - end = bounds[1]; - } + if (isWorldAreaEvent(event) && this.areas) { - this.plan.plan.splice(end, 0, this.planItemFromArea(event.previousContainer.data[event.previousIndex])); - this.scrollToEnd(); + this.plan.plan.splice(this.getEnd(), 0, this.planItemFromArea(event.previousContainer.data[event.previousIndex])); + } else { + moveItemInArray(this.plan.plan, event.previousIndex, this.getEnd()); + } + + this.scrollToEnd(); + } + + getEnd() { + let bounds = this.planElemFilterBounds(); + if (bounds) { + return bounds[1]; } else { - moveItemInArray(this.plan.plan, event.previousIndex, end); - this.scrollToEnd(); + return this.plan.plan.length; } }