Skip to content

Commit

Permalink
add edge response as hint on start drag for mouse/touch, #457
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Apr 22, 2022
1 parent 9ce6bac commit 048c6b6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions js/common/view/RatioHalf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Range from '../../../../dot/js/Range.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import optionize from '../../../../phet-core/js/optionize.js';
import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js';
import { DragListener, IPaint, Node, NodeOptions, Rectangle, RectangleOptions } from '../../../../scenery/js/imports.js';
import { DragListener, IPaint, Node, NodeOptions, Rectangle, RectangleOptions, SpeakingOptions } from '../../../../scenery/js/imports.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import ratioAndProportion from '../../ratioAndProportion.js';
import RatioTerm from '../model/RatioTerm.js';
Expand Down Expand Up @@ -319,16 +319,23 @@ class RatioHalf extends Rectangle {
}

startingY = positionProperty.value.y;
previousYOnLastVoicing = positionProperty.value.y;

this.viewSounds.grabSoundClip.play();
options.cueArrowsState.interactedWithMouseProperty.value = true;

options.setJumpingOverProportionShouldTriggerSound( true );
this.viewSounds.boundarySoundClip.onStartInteraction();

this.ratioHandNode.voicingSpeakFullResponse( {
const fullResponse: SpeakingOptions = {
contextResponse: null // If we ever have a context response, make sure we don't have go-beyond edge responses.
} );
};

const edgeHint = this.voicingHandPositionsDescriber.getGoBeyondContextResponse( this.ratio.tupleProperty.value, this.ratioTerm );
if ( edgeHint ) {
fullResponse.hintResponse = edgeHint;
}
this.ratioHandNode.voicingSpeakFullResponse( fullResponse );
},
drag: () => {
this._isBeingInteractedWithProperty.value = true;
Expand Down Expand Up @@ -392,6 +399,9 @@ class RatioHalf extends Rectangle {
else {
// No voicing if there hasn't been any movement
}

// Fire this once here so that on drag, if at edge, it will act like a go-beyond response on the first attempt
this.voicingHandPositionsDescriber.getGoBeyondContextResponse( this.ratio.tupleProperty.value, this.ratioTerm );
},

// phet-io
Expand Down

0 comments on commit 048c6b6

Please sign in to comment.