Minor tweaks to dropEndHandler, gonna reuse the end code for double click handler

cleanup
isakfredriksson 2 years ago committed by isark
parent d1d64b7960
commit b10619182e

@ -122,18 +122,23 @@ export class EditorComponent implements OnInit {
} }
dropEndHandler(event: CdkDragDrop<WorldArea[]> | CdkDragDrop<PlanElement[]>) { dropEndHandler(event: CdkDragDrop<WorldArea[]> | CdkDragDrop<PlanElement[]>) {
let bounds = this.planElemFilterBounds();
let end = this.plan.plan.length;
if (bounds) {
end = bounds[1];
}
if (isWorldAreaEvent(event) && this.areas) { if (isWorldAreaEvent(event) && this.areas) {
this.plan.plan.splice(end, 0, this.planItemFromArea(event.previousContainer.data[event.previousIndex])); this.plan.plan.splice(this.getEnd(), 0, this.planItemFromArea(event.previousContainer.data[event.previousIndex]));
this.scrollToEnd(); } else {
moveItemInArray(this.plan.plan, event.previousIndex, this.getEnd());
}
this.scrollToEnd();
}
getEnd() {
let bounds = this.planElemFilterBounds();
if (bounds) {
return bounds[1];
} else { } else {
moveItemInArray(this.plan.plan, event.previousIndex, end); return this.plan.plan.length;
this.scrollToEnd();
} }
} }

Loading…
Cancel
Save