Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces

util.math.cycleRestrict

Static function.

Assigns a numeric value to the set range. The range of values is considered to be closed in a ring. If a value is outside one of the ends of the range, the extra is counted off around the circl from the other end.

Returns value can be limited.

{ Number } util.math.cycleRestrict(value, min, max)

Parameters:

ParameterDefault valueDescription
value*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number

Value can be limited.

min*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number

Minimum limit.

max*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Number

Maximum limit.

* Mandatory parameter/option.

Example:

// Returns 110
ymaps.util.math.cycleRestrict(-250, -180, 180);
// Returns 60
ymaps.util.math.cycleRestrict(-300, -180, 180);
// Returns -170
ymaps.util.math.cycleRestrict(190, -180, 180);