1.0.0 • Published 7 years ago

array-sum-controller v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

Array Sum Controller

Array Sum Controller - will change values in array to maintain the same sum.

Values in array are in range 0-100.

Module could useful for related percentage values - like sliders in survery. For example, you have few sliders:

------O-----

------O-----

------O-----

------O-----

you move one of them, to max value, and the rest will resond with lowering its value:

-----------O

---O--------

---O--------

---O--------

Usage

var array = 50, 50, 50, 50;
var c = new ArraySumController(array); // or c.control(array);
c.setValue(0, 100); // set value 100 in first record; return array with values 100, 33.333..., 33.333..., 33.333...

License

MIT