Skip to content

Commit

Permalink
rename AccessibleNumberSpinner options, see #318
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Feb 28, 2024
1 parent cd0b432 commit 6816875
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
6 changes: 4 additions & 2 deletions js/NumberPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Range from '../../dot/js/Range.js';
import Utils from '../../dot/js/Utils.js';
import { Shape } from '../../kite/js/imports.js';
import InstanceRegistry from '../../phet-core/js/documentation/InstanceRegistry.js';
import { Color, FireListener, FireListenerOptions, HighlightPath, Font, LinearGradient, Node, NodeOptions, PaintColorProperty, Path, Rectangle, SceneryConstants, SceneryEvent, TColor, Text } from '../../scenery/js/imports.js';
import { Color, FireListener, FireListenerOptions, Font, HighlightPath, LinearGradient, Node, NodeOptions, PaintColorProperty, Path, Rectangle, SceneryConstants, SceneryEvent, TColor, Text } from '../../scenery/js/imports.js';
import AccessibleNumberSpinner, { AccessibleNumberSpinnerOptions } from '../../sun/js/accessibility/AccessibleNumberSpinner.js';
import generalBoundaryBoopSoundPlayer from '../../tambo/js/shared-sound-players/generalBoundaryBoopSoundPlayer.js';
import generalSoftClickSoundPlayer from '../../tambo/js/shared-sound-players/generalSoftClickSoundPlayer.js';
Expand Down Expand Up @@ -90,7 +90,7 @@ type SelfOptions = {

type ParentOptions = AccessibleNumberSpinnerOptions & NodeOptions;

export type NumberPickerOptions = SelfOptions & StrictOmit<ParentOptions, 'valueProperty' | 'enabledRangeProperty'>;
export type NumberPickerOptions = SelfOptions & StrictOmit<ParentOptions, 'valueProperty' | 'enabledRangeProperty' | 'pdomTimerDelay' | 'pdomTimerInterval'>;

// options to NumberPicker.createIcon
type CreateIconOptions = {
Expand Down Expand Up @@ -231,6 +231,8 @@ export default class NumberPicker extends AccessibleNumberSpinner( Node, 0 ) {
const keyboardStep = options.incrementFunction( valueProperty.get() ) - valueProperty.get();
options.keyboardStep = keyboardStep;
options.shiftKeyboardStep = keyboardStep;
options.pdomTimerDelay = options.timerDelay;
options.pdomTimerInterval = options.timerInterval;

const boundsRequiredOptionKeys = _.pick( options, Node.REQUIRES_BOUNDS_OPTION_KEYS );
super( _.omit( options, Node.REQUIRES_BOUNDS_OPTION_KEYS ) );
Expand Down
33 changes: 17 additions & 16 deletions js/accessibility/AccessibleNumberSpinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ import AccessibleValueHandler, { AccessibleValueHandlerOptions } from './Accessi
import TEmitter from '../../../axon/js/TEmitter.js';

const ACCESSIBLE_NUMBER_SPINNER_OPTIONS = [
'timerDelay',
'timerInterval'
'pdomTimerDelay',
'pdomTimerInterval'
];

type SelfOptions = {

// start to fire continuously after pressing for this long (milliseconds)
timerDelay?: number;
pdomTimerDelay?: number;

// fire continuously at this frequency (milliseconds),
timerInterval?: number;
pdomTimerInterval?: number;
};

type AccessibleNumberSpinnerOptions = SelfOptions & AccessibleValueHandlerOptions;
Expand All @@ -67,8 +68,8 @@ const AccessibleNumberSpinner = <SuperType extends Constructor<Node>>( Type: Sup
protected readonly pdomIncrementDownEmitter: TEmitter<[ boolean ]>;
protected readonly pdomDecrementDownEmitter: TEmitter<[ boolean ]>;

private _timerDelay = 400;
private _timerInterval = 100;
private _pdomTimerDelay = 400;
private _pdomTimerInterval = 100;

private readonly _disposeAccessibleNumberSpinner: () => void;

Expand All @@ -91,8 +92,8 @@ const AccessibleNumberSpinner = <SuperType extends Constructor<Node>>( Type: Sup
assertHasProperties( this, [ 'addInputListener' ] );

this._callbackTimer = new CallbackTimer( {
delay: this._timerDelay,
interval: this._timerInterval
delay: this._pdomTimerDelay,
interval: this._pdomTimerInterval
} );

this.pdomIncrementDownEmitter = new Emitter( { parameters: [ { valueType: 'boolean' } ] } );
Expand Down Expand Up @@ -182,28 +183,28 @@ const AccessibleNumberSpinner = <SuperType extends Constructor<Node>>( Type: Sup
};
}

public set timerDelay( value: number ) {
this._timerDelay = value;
public set pdomTimerDelay( value: number ) {
this._pdomTimerDelay = value;

if ( this._callbackTimer ) {
this._callbackTimer.delay = value;
}
}

public get timerDelay(): number {
return this._timerDelay;
public get pdomTimerDelay(): number {
return this._pdomTimerDelay;
}

public set timerInterval( value: number ) {
this._timerInterval = value;
public set pdomTimerInterval( value: number ) {
this._pdomTimerInterval = value;

if ( this._callbackTimer ) {
this._callbackTimer.interval = value;
}
}

public get timerInterval(): number {
return this._timerInterval;
public get pdomTimerInterval(): number {
return this._pdomTimerInterval;
}

/**
Expand Down

0 comments on commit 6816875

Please sign in to comment.