# all files / Github/diagram-js/lib/navigation/zoomscroll/ ZoomUtil.js

0% Statements 0/5
100% Branches 0/0
0% Functions 0/2
0% Lines 0/5

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25

     import {
      log10
    } from '../../util/Math';

    /**
     * Get step size for given range and number of steps.
     *
     * @param {Object} range
     * @param {number} range.min
     * @param {number} range.max
     */
    export function getStepSize(range, steps) {

      var minLinearRange = log10(range.min),
          maxLinearRange = log10(range.max);

      var absoluteLinearRange = Math.abs(minLinearRange) + Math.abs(maxLinearRange);

      return absoluteLinearRange / steps;
    }

    export function cap(range, scale) {
      return Math.max(range.min, Math.min(range.max, scale));
    }