Wrap shouldn't adjust a value already in the range

This commit is contained in:
Richard Davey 2023-01-24 13:43:15 +00:00
parent 50d0aeb391
commit 5d75d771f8

View file

@ -18,6 +18,12 @@
*/
var Wrap = function (value, min, max)
{
if (value >= min && value <= max)
{
// Skip modulo if already in range
return value;
}
var range = max - min;
return (min + ((((value - min) % range) + range) % range));