Skip to content

Commit

Permalink
Fix hold bottomcap for zero length holds
Browse files Browse the repository at this point in the history
  • Loading branch information
tillvit committed Jul 31, 2024
1 parent 4f05454 commit 100beca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/chart/component/notefield/Notefield.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class HoldObject extends Container {
private inactive

private wasActive = false
private lastLength: number | null = null

private elements!: HoldElements

Expand Down Expand Up @@ -254,12 +255,14 @@ export class HoldObject extends Container {

setLength(length: number) {
if (!this.loaded) return
if (this.lastLength == length) return
this.lastLength = length
const bbO =
this.metrics[`${this.note.type as HoldNoteType}BodyBottomOffset`]
const btO = this.metrics[`${this.note.type as HoldNoteType}BodyTopOffset`]

const states = ["Active", "Inactive"] as const
const sign = Math.sign(length)
const sign = length >= 0 ? 1 : -1
const absLength = Math.abs(length)
for (const state of states) {
this.elements[state].Body.height = Math.max(0, absLength + bbO - btO)
Expand Down

0 comments on commit 100beca

Please sign in to comment.