From 048c6b6d2a4dc886e715c16e24cca02bbd27f562 Mon Sep 17 00:00:00 2001 From: zepumph Date: Fri, 22 Apr 2022 15:46:30 -0600 Subject: [PATCH] add edge response as hint on start drag for mouse/touch, https://github.com/phetsims/ratio-and-proportion/issues/457 --- js/common/view/RatioHalf.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/js/common/view/RatioHalf.ts b/js/common/view/RatioHalf.ts index 34a8e68d..5586f6ac 100644 --- a/js/common/view/RatioHalf.ts +++ b/js/common/view/RatioHalf.ts @@ -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'; @@ -319,6 +319,7 @@ class RatioHalf extends Rectangle { } startingY = positionProperty.value.y; + previousYOnLastVoicing = positionProperty.value.y; this.viewSounds.grabSoundClip.play(); options.cueArrowsState.interactedWithMouseProperty.value = true; @@ -326,9 +327,15 @@ class RatioHalf extends Rectangle { 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; @@ -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