code: function (redraw) {
              var imgDim = this._image.getDimensions();
              var vFactor = (this._container.clientHeight - this._margin * 2) / imgDim.h;
              var hFactor = (this._container.clientWidth - this._margin * 2) / imgDim.w;
  
              // Set correct zoom level
              if (vFactor < hFactor && vFactor < 1 && this._zoomLevel > vFactor) {
                  // Fill vertical
                  this._zoomLevel = vFactor;
                  this.centerImage(false);
              }
              else if (hFactor < 1 && this._zoomLevel > hFactor) {
                  // Fill horizontal
                  this._zoomLevel = hFactor;
                  this.centerImage(false);
              }
              else {
                  // No need to redraw
                  return;
              }
  
              if (redraw === true) {
                  this.redraw();
              }
          }
docs: Fill drawing area with image as best as possible
  @param redraw