Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve condition slider percentage logic #77

Closed
tomjemmett opened this issue Sep 7, 2020 · 0 comments
Closed

Improve condition slider percentage logic #77

tomjemmett opened this issue Sep 7, 2020 · 0 comments
Assignees

Comments

@tomjemmett
Copy link
Member

The sum of the conditions sliders should not exceed 100%: currently this is enforced by setting the max-value of each slider independently to enforce this limit.

Instead, we should set the max-value's to 100% and use the following algorithm:

  1. if the percent sum exceeds 100% find the minimum percentage of the other sliders (the ones that haven't been updated)
  2. calculate the amount we need to reduce the sum by to reach 100%, and then equally divide this value by the number of sliders we are working with
  3. take the minimum value of 1 and 2, then reduce all of the sliders by this amount
  4. if the sum still exceeds 100%, remove the sliders which are now at 0% and repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant