All files / src/shared/lib/helpers zoom.ts

100% Statements 15/15
100% Branches 2/2
100% Functions 2/2
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 2023x   23x 3x 14x 2x     1x     23x 3x 16x 2x     1x    
export const zoomLevels = [25, 50, 100, 200, 400, 800];
 
export const zoomIn = (currentZoom: number) => {
  for (let i = 0; i < zoomLevels.length; i++) {
    if (zoomLevels[i] > currentZoom) {
      return zoomLevels[i];
    }
  }
  return zoomLevels[zoomLevels.length - 1];
};
 
export const zoomOut = (currentZoom: number) => {
  for (let i = zoomLevels.length - 1; i >= 0; i--) {
    if (zoomLevels[i] < currentZoom) {
      return zoomLevels[i];
    }
  }
  return zoomLevels[0];
};