Skip to content

Commit

Permalink
limit minimum measurement time, see #54
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 9, 2025
1 parent 3ad845f commit 7ccf6a6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions js/bloch-sphere/view/MeasurementTimerControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class MeasurementTimerControl extends Node {
// TODO: This should probably be rewritten to use thumbNode. Seems like that would be way simpler. See https://github.com/phetsims/quantum-measurement/issues/54.

const maxMeasurementTime = timeToMeasurementProperty.rangeProperty.value.max;
const minMeasurementTime = timeToMeasurementProperty.rangeProperty.value.getLength() / ( NUMBER_OF_MINOR_TICKS + 1 );
const thumbOffset = 30;
const thumbDimensions = new Dimension2( 30, 30 );
const timeToMeasurementSlider = new Slider( timeToMeasurementProperty, timeToMeasurementProperty.range, {
Expand All @@ -50,10 +51,13 @@ export default class MeasurementTimerControl extends Node {
thumbCenterLineStroke: null,
trackSize: SLIDER_TRACK_SIZE,
trackFillEnabled: Color.BLACK,
constrainValue: value => Utils.roundToInterval(
value,
timeToMeasurementProperty.rangeProperty.value.max / ( NUMBER_OF_MINOR_TICKS + 1 )
),
constrainValue: value => {
const roundedValue = Utils.roundToInterval(
value,
timeToMeasurementProperty.rangeProperty.value.max / ( NUMBER_OF_MINOR_TICKS + 1 )
);
return Math.max( minMeasurementTime, roundedValue );
},
orientation: Orientation.HORIZONTAL,
majorTickLength: 10,
minorTickLength: 5
Expand Down

0 comments on commit 7ccf6a6

Please sign in to comment.