myDiagram.scrollMode = checked ? go.Diagram.InfiniteScroll : go.Diagram.DocumentScroll;

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 交流群
GoJS 交流群 (769862113)