Skip to content

Commit

Permalink
no go-beyond edge alerts when dragging with mouse/touch (drag or endD…
Browse files Browse the repository at this point in the history
…rag), #457
  • Loading branch information
zepumph committed Apr 22, 2022
1 parent ad2c071 commit ce8d4d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion js/common/view/RatioHalf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class RatioHalf extends Rectangle {
this.viewSounds.boundarySoundClip.onStartInteraction();

this.ratioHandNode.voicingSpeakFullResponse( {
contextResponse: null
contextResponse: null // If we ever have a context response, make sure we don't have go-beyond edge responses.
} );
},
drag: () => {
Expand All @@ -347,6 +347,7 @@ class RatioHalf extends Rectangle {
this.ratioHandNode.voicingSpeakFullResponse( {
nameResponse: null,
contextResponse: this.getSingleHandContextResponse( this.voicingHandPositionsDescriber, voicingBothHandsDescriber, {
supportGoBeyondEdgeResponses: false, // no go-beyond-edge responses for mouse/touch
distanceResponseType: DistanceResponseType.DISTANCE_PROGRESS
} ),
hintResponse: null
Expand Down Expand Up @@ -382,6 +383,7 @@ class RatioHalf extends Rectangle {
this.ratioHandNode.voicingSpeakFullResponse( {
nameResponse: null,
contextResponse: this.getSingleHandContextResponse( this.voicingHandPositionsDescriber, voicingBothHandsDescriber, {
supportGoBeyondEdgeResponses: false, // no go-beyond-edge responses for mouse/touch
distanceResponseType: DistanceResponseType.DISTANCE_REGION
} ),
hintResponse: null
Expand Down
16 changes: 12 additions & 4 deletions js/common/view/describers/HandPositionsDescriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ type GetDistanceProgressStringOptions = {
};

export type HandContextResponseOptions = {
supportGoBeyondEdgeResponses?: boolean;
distanceResponseType?: DistanceResponseType;
};

Expand Down Expand Up @@ -253,15 +254,19 @@ class HandPositionsDescriber {

getSingleHandContextResponse( ratioTerm: RatioTerm, tickMarkView: TickMarkView, providedOptions?: HandContextResponseOptions ): string {

const options = optionize<HandContextResponseOptions, HandContextResponseOptions>()( {
const options = optionize<HandContextResponseOptions>()( {

supportGoBeyondEdgeResponses: true,

// By default, let the describer decide if we should have distance progress or region
distanceResponseType: DistanceResponseType.COMBO
}, providedOptions );

const ratioLockedEdgeResponse = this.getGoBeyondContextResponse( this.ratioTupleProperty.value, ratioTerm );
if ( ratioLockedEdgeResponse ) {
return ratioLockedEdgeResponse;
if ( options.supportGoBeyondEdgeResponses ) {
const ratioLockedEdgeResponse = this.getGoBeyondContextResponse( this.ratioTupleProperty.value, ratioTerm );
if ( ratioLockedEdgeResponse ) {
return ratioLockedEdgeResponse;
}
}

let distanceClause = null;
Expand Down Expand Up @@ -333,11 +338,14 @@ class HandPositionsDescriber {
// TODO: capitalized is currently always used, but it would be nice to improve the implementation for voicing context responses, https://github.com/phetsims/ratio-and-proportion/issues/461
getBothHandsDistance( capitalized: boolean, providedOptions?: HandContextResponseOptions ): string {
const options = optionize<HandContextResponseOptions>()( {
supportGoBeyondEdgeResponses: true,

// By default, let the describer decide if we should have distance progress or region
distanceResponseType: DistanceResponseType.COMBO
}, providedOptions );

// TODO: manage edge response here for both hands instead of in the BothHandsDescriber: https://github.com/phetsims/ratio-and-proportion/issues/457

switch( options.distanceResponseType ) {
case DistanceResponseType.COMBO:
return this.getBothHandsComboDistance( capitalized );
Expand Down

0 comments on commit ce8d4d8

Please sign in to comment.