adapt the zoom level to fit the viewport to all visible objects.
421847
function(ms) {
    var axes = this._cam.mainAxes();
    var intervals = [ new utils.Range(), new utils.Range(), new utils.Range() ];
    this.forEach(function(obj) {
      if (!obj.visible()) {
        return;
      }
      obj.updateProjectionIntervals(axes[0], axes[1], axes[2], intervals[0],
                                    intervals[1], intervals[2]);
    });
    this._fitToIntervals(axes, intervals, ms);
  }
1101938
def zoom_fit(self):
        
        viewer = self.getfocus_viewer()
        if hasattr(viewer, 'zoom_fit'):
            viewer.zoom_fit()
        return True
911887
def zoom_fit(self):
        

        zoom = self.grid.grid_renderer.zoom

        grid_width, grid_height = self.grid.GetSize()

        rows_height = self._get_rows_height() + \
            (float(self.grid.GetColLabelSize()) / zoom)
        cols_width = self._get_cols_width() + \
            (float(self.grid.GetRowLabelSize()) / zoom)

        # Check target zoom for rows
        zoom_height = float(grid_height) / rows_height

        # Check target zoom for columns
        zoom_width = float(grid_width) / cols_width

        # Use the minimum target zoom from rows and column target zooms
        target_zoom = min(zoom_height, zoom_width)

        # Zoom only if between min and max

        if config["minimum_zoom"] < target_zoom < config["maximum_zoom"]:
            self.zoom(target_zoom)
467048
function updateViewport() {
  threshold._viewport.height = window.innerHeight;
  threshold._viewport.width = window.innerWidth;
}
1118867
function() {
        var changed = this._changedObjs;
        // Adjust the viewport
        if (this._dirtyViewport) {
            this._setViewport();
            this._dirtyViewport = false;
        }

        //if no objects have been changed, stop
        if (!changed.length) return;

        var i = 0,
            k = changed.length;
        //loop over all DOM elements needing updating
        for (; i < k; ++i) {
            changed[i].draw()._changed = false;
        }

        //reset DOM array
        changed.length = 0;
    }
605852
def zoom(self, factor):
        """"""
        editor = self.get_current_editorstack().get_current_editor()
        if factor == 0:
            font = self.get_plugin_font()
            editor.set_font(font)
        else:
            font = editor.font()
            size = font.pointSize() + factor
            if size > 0:
                font.setPointSize(size)
                editor.set_font(font)
        editor.update_tab_stop_width_spaces()
1275781
function zoomTo(ratio, pivot, _originalEvent) {
    var options = this.options,
        canvasData = this.canvasData;
    var width = canvasData.width,
        height = canvasData.height,
        naturalWidth = canvasData.naturalWidth,
        naturalHeight = canvasData.naturalHeight;


    ratio = Number(ratio);

    if (ratio >= 0 && this.ready && !this.disabled && options.zoomable) {
      var newWidth = naturalWidth * ratio;
      var newHeight = naturalHeight * ratio;

      if (dispatchEvent(this.element, EVENT_ZOOM, {
        originalEvent: _originalEvent,
        oldRatio: width / naturalWidth,
        ratio: newWidth / naturalWidth
      }) === false) {
        return this;
      }

      if (_originalEvent) {
        var pointers = this.pointers;

        var offset = getOffset(this.cropper);
        var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
          pageX: _originalEvent.pageX,
          pageY: _originalEvent.pageY
        };

        // Zoom from the triggering point of the event
        canvasData.left -= (newWidth - width) * ((center.pageX - offset.left - canvasData.left) / width);
        canvasData.top -= (newHeight - height) * ((center.pageY - offset.top - canvasData.top) / height);
      } else if (isPlainObject(pivot) && isNumber(pivot.x) && isNumber(pivot.y)) {
        canvasData.left -= (newWidth - width) * ((pivot.x - canvasData.left) / width);
        canvasData.top -= (newHeight - height) * ((pivot.y - canvasData.top) / height);
      } else {
        // Zoom from the center of the canvas
        canvasData.left -= (newWidth - width) / 2;
        canvasData.top -= (newHeight - height) / 2;
      }

      canvasData.width = newWidth;
      canvasData.height = newHeight;
      this.renderCanvas(true);
    }

    return this;
  }
1138940
def on_resize(self, event):
        
        self._update_transforms()
        
        if self._central_widget is not None:
            self._central_widget.size = self.size
            
        if len(self._vp_stack) == 0:
            self.context.set_viewport(0, 0, *self.physical_size)
981762
def unzoom_all(self,event=None,panel=None):
        
        if panel is None: panel = self.current_panel
        self.panels[panel].unzoom_all(event=event)
523970
function () {
            var viewportEl = this.$viewport[0],
                dimensionsEl = viewportEl;

            // use the documentElement for viewport dimensions
            // if we are using the window as the viewport
            if (viewportEl === window) {
                dimensionsEl = document.documentElement;
            }
            // setup initial state
            this.state = {
                scrollTop: viewportEl.scrollTop,
                scrollLeft: viewportEl.scrollLeft,
                viewportDimensions: {
                    clientWidth: dimensionsEl.clientWidth,
                    clientHeight: dimensionsEl.clientHeight,
                    offsetWidth: dimensionsEl.offsetWidth,
                    offsetHeight: dimensionsEl.offsetHeight
                },
                zoomState: {
                    zoom: 1,
                    prevZoom: 0,
                    zoomMode: null
                },
                initialWidth: 0,
                initialHeight: 0,
                totalWidth: 0,
                totalHeight: 0
            };
            this.zoomLevels = [];
        }
512172
function() {
        var mapRes = this.map.getResolution();
        var targetRes = this.ovmap.getResolution();
        var resRatio = targetRes / mapRes;
        if(resRatio > this.maxRatio) {
            // zoom in overview map
            targetRes = this.minRatio * mapRes;            
        } else if(resRatio <= this.minRatio) {
            // zoom out overview map
            targetRes = this.maxRatio * mapRes;
        }
        var center;
        if (this.ovmap.getProjection() != this.map.getProjection()) {
            center = this.map.center.clone();
            center.transform(this.map.getProjectionObject(),
                this.ovmap.getProjectionObject() );
        } else {
            center = this.map.center;
        }
        this.ovmap.setCenter(center, this.ovmap.getZoomForResolution(
            targetRes * this.resolutionFactor));
        this.updateRectToMap();
    }
902506
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();
            }
        }
1343455
private void adaptContentContainerVisibility() {
        if (contentContainer != null) {
            if (isCustomViewUsed()) {
                contentContainer.setVisibility(View.VISIBLE);
                notifyOnAreaShown(Area.CONTENT);
            } else {
                contentContainer.setVisibility(View.GONE);
                notifyOnAreaHidden(Area.CONTENT);
            }
        }
    }
507456
private void adaptDividerVisibilities() {
        if (scrollView != null) {
            adaptDividerVisibilities(scrollView.isScrolledToTop(), scrollView.isScrolledToBottom(),
                    false);
        } else if (listView != null) {
            adaptDividerVisibilities(isListViewScrolledToTop(listView),
                    isListViewScrolledToBottom(listView), false);
        }
    }
425126
function zoomed () {
    // Get the height and width
    height = el.clientHeight
    width = el.clientWidth

    // Set the map tile size
    tile.size([width, height])

    // Get the current display bounds
    var bounds = display.llBounds()

    // Project the bounds based on the current projection
    var psw = projection(bounds[0])
    var pne = projection(bounds[1])

    // Based the new scale and translation vector off the current one
    var scale = projection.scale() * 2 * Math.PI
    var translate = projection.translate()

    var dx = pne[0] - psw[0]
    var dy = pne[1] - psw[1]

    scale = scale * (1 / Math.max(dx / width, dy / height))
    projection
      .translate([width / 2, height / 2])
      .scale(scale / 2 / Math.PI)

    // Reproject the bounds based on the new scale and translation vector
    psw = projection(bounds[0])
    pne = projection(bounds[1])
    var x = (psw[0] + pne[0]) / 2
    var y = (psw[1] + pne[1]) / 2
    translate = [width - x, height - y]

    // Update the Geo tiles
    tile
      .scale(scale)
      .translate(translate)

    // Get the new set of tiles and render
    renderTiles(tile())
  }
767468
private void adaptNavigationVisibility() {
        if (isSplitScreen()) {
            if (navigationFragmentContainer != null && cardView != null && toolbarLarge != null) {
                navigationFragmentContainer
                        .setVisibility(isNavigationHidden() ? View.GONE : View.VISIBLE);
                toolbarLarge.hideNavigation(isNavigationHidden());
                int preferenceScreenHorizontalMargin =
                        getResources().getDimensionPixelSize(R.dimen.card_view_horizontal_margin);
                int preferenceScreenMarginRight =
                        getResources().getDimensionPixelSize(R.dimen.card_view_margin_right);
                int cardViewIntrinsicMargin =
                        getResources().getDimensionPixelSize(R.dimen.card_view_intrinsic_margin);
                FrameLayout.LayoutParams cardViewLayoutParams =
                        (FrameLayout.LayoutParams) cardView.getLayoutParams();
                cardViewLayoutParams.gravity =
                        isNavigationHidden() ? Gravity.CENTER_HORIZONTAL : Gravity.NO_GRAVITY;
                int marginStart = (isNavigationHidden() ? preferenceScreenHorizontalMargin :
                        navigationWidth) - cardViewIntrinsicMargin;
                int marginEnd = (isNavigationHidden() ? preferenceScreenHorizontalMargin :
                        preferenceScreenMarginRight) - cardViewIntrinsicMargin;
                setMarginStart(cardViewLayoutParams, marginStart);
                setMarginEnd(cardViewLayoutParams, marginEnd);
            }
        } else {
            if (getSelectedNavigationPreference() != null) {
                if (isNavigationHidden()) {
                    hideToolbarNavigationIcon();
                } else {
                    showToolbarNavigationIcon();
                }
            } else if (isNavigationHidden() && navigationFragment != null &&
                    navigationFragment.getCallback() == null) {
                if (navigationFragment.getNavigationPreferenceCount() > 0) {
                    navigationFragment.selectNavigationPreference(0, null);
                } else {
                    finish();
                }
            }
        }
    }
89682
def zoom_out(self):
        """"""

        zoom = self.grid.grid_renderer.zoom

        target_zoom = zoom * (1 - config["zoom_factor"])

        if target_zoom > config["minimum_zoom"]:
            self.zoom(target_zoom)