phetsims / number-line-integers

"Number Line: Integers" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 4 forks source link

imageSelectionFunction references images based on index in an array #133

Closed Luisav1 closed 8 months ago

Luisav1 commented 8 months ago

Found while working on https://github.com/phetsims/joist/issues/958. The imageSelectionFunction within ElevationSceneView currently relies on referencing images based on their index number within an array, which appears to be fragile. This dependency on image order existed before the R&C feature, originally committed by @jbphet in https://github.com/phetsims/number-line-integers/commit/d855bd4d66f2bf2a49ecafacbccce0db708c8f61.

Is there be an alternative approach that reduces this dependency? Assigning @jbphet as he did the original commit.

jbphet commented 8 months ago

'Tis a fair point - using indexes the way I did here is quite fragile. I've changed the code to use Maps instead. @Luisav1 - please review and close if you're good with it. I don't know if this impacts the work you're doing or is more of an editorial observation, but I thought I'd pass this back to you either way for at least a quick look.

Luisav1 commented 8 months ago

@jbphet Thanks for the update. The transition to using maps looks solid. Although it doesn't directly impact the work I'm doing, it does offer an easier way of aligning the images, I believe. Closing the issue now.