Skip to content

Commit

Permalink
more working on converting the view, #404
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Oct 21, 2021
1 parent 04ad335 commit 5630e5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
13 changes: 10 additions & 3 deletions js/common/view/BothHandsPDOMNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,23 @@ import ratioAndProportion from '../../ratioAndProportion.js';
import ratioAndProportionStrings from '../../ratioAndProportionStrings.js';
import BothHandsInteractionListener from './BothHandsInteractionListener.js';
import ViewSounds from './sound/ViewSounds.js';
import BothHandsDescriber from './describers/BothHandsDescriber.js';

// constants
const OBJECT_RESPONSE_DELAY = 500;

class BothHandsPDOMNode extends Node {

private bothHandsDescriber: BothHandsDescriber;
private antecedentInteractedWithProperty: Property<boolean>;
private consequentInteractedWithProperty: Property<boolean>;
private bothHandsFocusedProperty: Property<boolean>;
private viewSounds: ViewSounds;

/**
* @param {Object} config
*/
constructor( config ) {
constructor( config: any ) {

config = merge( {

Expand Down Expand Up @@ -116,7 +123,7 @@ class BothHandsPDOMNode extends Node {
Property.multilink( [
this.antecedentInteractedWithProperty,
this.consequentInteractedWithProperty
], ( antecedentInteractedWith, consequentInteractedWith ) => {
], ( antecedentInteractedWith: boolean, consequentInteractedWith: boolean ) => {
config.cueArrowsState.bothHands.interactedWithProperty.value = antecedentInteractedWith || consequentInteractedWith;

// If both hands have been interacted with, then no need for individual cues either
Expand All @@ -128,7 +135,7 @@ class BothHandsPDOMNode extends Node {
this.antecedentInteractedWithProperty,
this.consequentInteractedWithProperty,
this.bothHandsFocusedProperty
], ( antecedentInteractedWith, consequentInteractedWith, bothHandsFocused ) => {
], ( antecedentInteractedWith: boolean, consequentInteractedWith: boolean, bothHandsFocused: boolean ) => {
config.cueArrowsState.bothHands.antecedentCueDisplayedProperty.value = !antecedentInteractedWith && bothHandsFocused;
config.cueArrowsState.bothHands.consequentCueDisplayedProperty.value = !consequentInteractedWith && bothHandsFocused;
} );
Expand Down
10 changes: 6 additions & 4 deletions js/common/view/describers/TickMarkDescriberTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@

import EnumerationProperty from '../../../../../axon/js/EnumerationProperty.js';
import NumberProperty from '../../../../../axon/js/NumberProperty.js';
import TickMarkView from '../TickMarkView.js';
import TickMarkView, { TickMarkViewType } from '../TickMarkView.js';
import TickMarkDescriber from './TickMarkDescriber.js';

QUnit.module( 'TickMarkDescriber' );

QUnit.test( 'getRelativePositionAndTickMarkNumberForPosition', assert => {
const tickMarkViewProperty = new EnumerationProperty( TickMarkView, TickMarkView.VISIBLE );

// @ts-ignore
const tickMarkViewProperty = new EnumerationProperty( TickMarkView as TickMarkViewType, TickMarkView.VISIBLE );
const tickMarkRangeProperty = new NumberProperty( 10 );

const getMessage = ( position, supplemental ) => {
const getMessage = ( position: number, supplemental: string ) => {
return `${supplemental}, Position: ${position}, TickMarkView: ${tickMarkViewProperty.value}, tick mark range: ${tickMarkRangeProperty.value}`;
};
const tickMarkDescriber = new TickMarkDescriber( tickMarkRangeProperty, tickMarkViewProperty );

const testTickMarkOutput = ( position, expectedData ) => {
const testTickMarkOutput = ( position: number, expectedData: { ordinalPosition?: string, tickMarkPosition?: string|number, relativePosition: string } ) => {
const actualData = tickMarkDescriber.getRelativePositionAndTickMarkNumberForPosition( position );
if ( expectedData.ordinalPosition ) {
assert.ok( typeof actualData.ordinalPosition === 'string', getMessage( position, 'should be defined as a string' ) );
Expand Down

0 comments on commit 5630e5d

Please sign in to comment.