Skip to content

Commit

Permalink
Allow deleting points
Browse files Browse the repository at this point in the history
  • Loading branch information
newcat committed Mar 25, 2024
1 parent d0beca5 commit 4da6953
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/automation/AutomationEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<!-- points ----->
<circle
v-for="p in points"
@mousedown="mousedown(p.id)"
@mousedown="mousedown($event, p.id)"
:key="p.id + '-point'"
:class="{ '--dragged': draggedPoint === p }"
:cx="getXCoordinate(p.unit)"
Expand Down Expand Up @@ -195,7 +195,11 @@ function getValue(yCoordinate: number) {
return clamp((-yCoordinate + padding.value) / (height.value - 2 * padding.value) + 1, 0, 1);
}
function mousedown(id: string) {
function mousedown(ev: MouseEvent, id: string) {
if (ev.button === 2) {
props.automationClip.removePoint(id);
return;
}
draggedPoint.value = points.value.find((p) => p.id === id) ?? null;
}
Expand Down
5 changes: 5 additions & 0 deletions src/automation/automation.libraryItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export class AutomationLibraryItem extends LibraryItem<AutomationLibraryItemStat
this.events.pointsUpdated.emit();
}

public removePoint(id: string) {
this.points = this.points.filter((p) => p.id !== id);
this.events.pointsUpdated.emit();
}

public sortPoints() {
this.points.sort((a, b) => a.unit - b.unit);
}
Expand Down

0 comments on commit 4da6953

Please sign in to comment.