# Class SerpentineLayout

GoJS® Diagramming Components
version 3.0.7
by Northwoods Software®

This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. See the Extensions intro page for more information.

#### Hierarchy

- Layout
  - SerpentineLayout

A custom go.Layout that lays out a chain of nodes in a snake-like fashion.

This layout assumes the graph is a chain of Nodes, positioning nodes in horizontal rows back and forth, alternating between left-to-right and right-to-left within the wrap limit. spacing controls the distance between nodes. leftSpot and rightSpot determine the Spots to use for the go.Link.fromSpot and go.Link.toSpot.

When this layout is the Diagram.layout, it is automatically invalidated when the viewport changes size.

If you want to experiment with this extension, try the Serpentine Layout sample.

#####
Index

### Constructors

constructor

### Accessors

leftSpot
rightSpot
root
spacing
wrap

### Methods

cloneProtected
doLayout

#####
Inherited Index

### Accessors

Layout.arrangementOrigin
Layout.boundsComputation
Layout.diagram
Layout.group
Layout.isInitial
Layout.isOngoing
Layout.isRealtime
Layout.isRouting
Layout.isValidLayout
Layout.isViewportSized
Layout.network

### Methods

Layout.collectParts
Layout.commitLayout
Layout.copy
Layout.createNetwork
Layout.getLayoutBounds
Layout.initialOrigin
Layout.invalidateLayout
Layout.makeNetwork
Layout.updateParts

## Constructors

### constructor

- new SerpentineLayout(init?: Partial<SerpentineLayout>): SerpentineLayout

- Constructs a SerpentineLayout and sets the isViewportSized property to true.

  #### Parameters

  - ##### `Optional` init: Partial<SerpentineLayout>

  #### Returns SerpentineLayout

## Accessors

### leftSpot
: Spot

- Gets or sets the Spot to use on the left side of a Node.

  The default value is go.Spot.Left.

### rightSpot
: Spot

- Gets or sets the Spot to use on the right side of a Node.

  The default value is go.Spot.Right.

### root
: Node

- Gets or sets the starting node of the sequence.

  The default value is null, which causes the layout to look for a node without any incoming links.

### spacing
: Size

- Gets or sets the go.Size whose width specifies the horizontal space between nodes and whose height specifies the minimum vertical space between nodes.

  The default value is 30x30.

### wrap
: number

- Gets or sets the total width of the layout.

  The default value is NaN, which for go.Diagram.layouts means that it uses the go.Diagram.viewportBounds.

## Methods

### `Override` cloneProtected

- cloneProtected(copy: SerpentineLayout): void

- Copies properties to a cloned Layout.

  #### Parameters

  - ##### copy: SerpentineLayout

  #### Returns void

### `Override` doLayout

- doLayout(collection: Diagram | Iterable<Part> | Group): void

- This method actually positions all of the Nodes, assuming that the ordering of the nodes is given by a single link from one node to the next. This respects the spacing and wrap properties to affect the layout.

  #### Parameters

  - ##### collection: Diagram | Iterable<Part> | Group

  #### Returns void

Copyright © 1998-2024 by Northwoods Software Corporation.