myDiagram.scrollMode = checked ? go.ScrollMode.Infinite : go.ScrollMode.Document;
    

      function positionfunc(diagram, pos) {
        var size = diagram.grid.gridCellSize;
        return new go.Point(
          Math.round(pos.x / size.width) * size.width,
          Math.round(pos.y / size.height) * size.height);
      }
    

      function scalefunc(diagram, scale) {
        var oldscale = diagram.scale;
        if (scale > oldscale) {
          return oldscale + 0.25;
        } else if (scale < oldscale) {
          return oldscale - 0.25;
        }
        return oldscale;
      }
    

This demonstrates new scrolling and scaling options available in GoJS 1.5.


GoJS Features in this sample

Grid Patterns

GoJS provides functionality to display a grid of lines drawn at regular intervals. Grid Panels can also force dragged parts to be aligned on grid points, and resize parts to be multiples of the grid cell size.

Grids are implemented using a type of Panel, Panel.Grid. Grid Panels, like most other types of Panels, can be used within Nodes or any other kind of Part. However when they are used as the Diagram.grid, they are effectively infinite in extent.

More information can be found in the GoJS Intro.

Related samples