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 };