Function clampScope

  • Get progress relative to a given scope and then clamp it within another range.

    The function first scales the value relative to scopeProp using the scoped function, and then clamps the result within clampProp using the clamp function.

    Parameters

    • value: number

      The value to be scaled and clamped.

    • scopeProp: number[] = ...

      The scope within which the value will be scaled.

    • clampProp: number[] = ...

      The range to clamp the scaled value within.

    Returns number

    Example

    clampScope(0.38, [0.35, 1]); // => 0.046
    clampScope(0.38, [0.35, 1], [0.1, 1]); // => 0.1