heldentodd / xray-diffraction

This repository contains the code for one simulation, but eventually three are planned: bragg-law, Single Crystal Diffraction, and Powder Diffraction.
GNU General Public License v3.0
2 stars 1 forks source link

deprecation warning for use of MovableDragHandler #4

Closed pixelzoom closed 4 years ago

pixelzoom commented 4 years ago

Related to #1 (code review).

  • [ ] Does the sim output any deprecation warnings? Run with ?deprecationWarnings. Do not use deprecated methods in new code.

There are 4 warnings:

deprecationWarning.js:18 Deprecation warning: SimpleDragHandler is deprecated, please use DragListener instead (SliderTrack.js)
deprecationWarning.js:18 Deprecation warning: ButtonListener is deprecated, please use FireListener instead (SliderThumb.js)
deprecationWarning.js:18 Deprecation warning: DownUpListener is deprecated, please use PressListener instead (SliderThumb.js)
deprecationWarning.js:18 Deprecation warning: MovableDragHandler is deprecated, please use DragListener instead (XrayDiffractionScreenView.js)

The first 3 are in PhET common code, and there's nothing that you can do about them. I've reported them in https://github.com/phetsims/sun/issues/599.

The last on is in XrayDiffractionScreenView.js, and I recommend addressing it. Deprecated code is code that has been replaced by a superior solution, is no longer supported, and will eventually be deleted. In this case, MovableDragHandler was an method of dragging things. DragListener (in the scenery repository) is its replacement. Let me know if you need assistance migrating from MovableDragHandler to DragListener.

heldentodd commented 4 years ago

Wow, this took a lot longer for me than it should have. I'm glad to have taken the time muddling through because I learned a fair amount. In the end, it was a simple rewrite to change the MovableDragHandler call to the DragListener. They are almost the same function (the "handler" doesn't seem to handle anything extra). Setting the useParentOffset: true for DragListener was important. In the end, the code is shorter and more consistent. I was also able get rid of ToolIconListener.js entirely.