-
Notifications
You must be signed in to change notification settings - Fork 443
Description
Loading a new set is currently recalculating the same result 10-16 times. This is due to using change() on dom objects to trigger an update of the UI. For example:
damage-calc/src/js/shared_controls.js
Line 630 in d81a18c
| $(".status").change(); |
damage-calc/src/js/shared_controls.js
Line 722 in d81a18c
| moveObj.change(); |
damage-calc/src/js/shared_controls.js
Line 785 in d81a18c
| abilityObj.change(); |
This happens numerous times throughout the function and each time change() is called on an object with the class calc-trigger, it causes the calc to redo the calculations even though none of the input has changed. I can see that the intended result of using change() seems to just be to update the UI so that the appropriate options like ability toggles or number of move hits show up and not to actually alter the damage calculation results.
Another 6 extra duplicate calculations come from here for pokemon with alternate forms.
damage-calc/src/js/shared_controls.js
Line 930 in d81a18c
| baseStat.keyup(); |
Perhaps the UI updating code can be separated out and called directly when needed instead of just using change() is updated to prevent these duplicate calls. While it doesn't really affect the user experience for the base calc, it does improve performance for anyone who forks the calc and adds additional functionality to performCalculations