Skip to main content

Navigator

Navigator is a UI widget that displays a smaller view into a larger diagram.

Learn more about the Navigator plugin.

constructor

constructor(opt?: Navigator.Options);

The ui.Navigator constructor accepts the following parameters:

paperScroller

[optional] The paper scroller. See ui.PaperScroller plugin for more details.

width

[optional] The width of the navigator view.

height

[optional] The height of the navigator view.

padding

[optional] The initial padding between the small paper inside the navigator, and the navigator view rectangle edges.

zoomOptions

[optional] An object with parameters controlling the zoom functions. zoomOptions.min and zoomOptions.max determine the minimum and the maximum zoom allowed when zooming via dragging the rectangle corner inside the navigator.

paperConstructor

[optional] The type of the paper. It defaults to joint.dia.Paper. This is only useful if you use a different paper type for rendering your graphics. In case you inherit from joint.dia.Paper to implement some specific rendering, you can just pass your constructor function to this parameter and use the paperOptions parameter to pass additional options to your special paper.

paperOptions

[optional] Options object that will be passed to the internal paper used for rendering graphics.

useContentBBox

[optional] When enabled, the navigator only shows the content of the paper rather than the entire scrollable area. An object with a single option can be passed here to calculate the content size from the model { useModelGeometry: true }. It defaults to false.

preserveAspectRatio

[optional] If disabled, the navigator will stretch the content to fit the entire navigator space. It defaults to true.

Methods

render()

navigator.render(): this;

Render the navigator. You should call this method after you have appended the navigator view root HTML element to your container.

remove()

navigator.render(): this;

Remove the navigator, and clean up all its registered event handlers. Call this once you do not need the navigator anymore.

updateCurrentView()

navigator.updateCurrentView(): void;

Updates the navigator's viewport based on the associated paperScroller state. The method is debounced (the invoking is delayed until after 0 milliseconds have elapsed since the last time the method was invoked), and is called automatically when the paperScroller is scrolled or zoomed.

freeze()

navigator.freeze(opt?: dia.Paper.FreezeOptions): void;

Freeze the paper of the navigator. In this state, the paper does not automatically re-render upon changes in the graph. This is useful when for instance the navigator is collapsed (not visible on the screen). For more information see paper.freeze().

unfreeze()

navigator.unfreeze(opt?: dia.Paper.UnfreezeOptions): void;

Unfreeze the paper of the navigator. For more information see paper.unfreeze().

Events

pan:start

Triggered when the user starts panning the viewport.

The handler is passed an evt (the mousedown event).

pan:stop

Triggered when the user stops panning the viewport.

The handler is passed an evt (the mouseup event).

zoom:start

Triggered when the user starts zooming the viewport.

The handler is passed an evt (the mousedown event).

zoom:stop

Triggered when the user stops zooming the viewport.

The handler is passed an evt (the mouseup event).

Types

Options

interface Options extends mvc.ViewOptions<undefined> {
paperConstructor?: typeof dia.Paper;
paperOptions?: dia.Paper.Options;
paperScroller?: PaperScroller;
/**
* @deprecated use zoom instead
*/
zoomOptions?: PaperScroller.ZoomOptions;
zoom?: boolean | PaperScroller.ZoomOptions;
width?: number;
height?: number;
padding?: number;
useContentBBox?: UseContentBBox;
preserveAspectRatio?: boolean;
}

UseContentBBox

type UseContentBBox = boolean | { useModelGeometry?: boolean };