Skip to content

Commit

Permalink
fix javascript number imprecision when snapping to tick mark, #457
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed May 25, 2022
1 parent 42aa75d commit 94b175f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion js/common/view/RatioHalf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ class RatioHalf extends Rectangle {
// iterate through model values of each tick mark
for ( let i = TOTAL_RANGE.min; i < TOTAL_RANGE.max; i += tickMarkStep ) {
if ( Math.abs( yValue - i ) < tickMarkStep * SNAP_TO_TICK_MARK_THRESHOLD ) {
return i;

// Bug occurs when dragging to the top with tick marks enabled, the value is 1, but snaps to .999999 unless rounded
return rapConstants.toFixed( i ); // eslint-disable-line bad-sim-text
}
}
}
Expand Down

0 comments on commit 94b175f

Please sign in to comment.