Options for the PanZoom widget. This widget is used internally by the Toolkit and is not something users of the library will need to interact with.

interface PanZoomOptions {
    background?: Background;
    canvasElement: Element;
    clamp?: boolean;
    clampToBackground?: boolean;
    clampToBackgroundExtents?: boolean;
    clampZoom?: boolean;
    consumeRightClick?: boolean;
    enableAnimation?: boolean;
    enablePan?: boolean;
    enabled?: boolean;
    events?: {
        maybeZoom?: Function;
        mousedown?: Function;
        mousemove?: Function;
        mouseup?: Function;
        pan?: Function;
        transformOrigin?: Function;
        zoom?: Function;
    };
    filter?: Function;
    getOffset: ((el) => PointXY);
    getOffsetRelativeToRoot: ((el) => PointXY);
    getSize: ((el) => Size);
    idFunction: ((e) => string);
    panDistance?: number;
    panFilter?: ((el) => boolean);
    panWithMetaKey?: boolean;
    smartMinimumZoom?: boolean;
    viewportElement: Element;
    wheel: WheelOptions;
    zoom?: number;
    zoomRange?: ZoomRange;
}

Properties

background?: Background

Optional background. Can also be set via setBackground(..)

canvasElement: Element

The element to apply pan/zoom to.

clamp?: boolean

Whether to clamp when panning such that there is always content visible. Defaults to true.

clampToBackground?: boolean

Whether or not to clamp to the background image. This flag means the widget will always ensure at least some of the background is visible. See clampToBackgroundExtents for a variant of this. Defaults to false.

clampToBackgroundExtents?: boolean

Clamps movement so that when zoomed out, the background image always fills the viewport. Defaults to false.

clampZoom?: boolean

Whether to clamp when zooming such that there is always content visible. Defaults to true.

consumeRightClick?: boolean

Useful for development: set this to false if you don't want the widget to consume context menu clicks.

enableAnimation?: boolean

Enable animations for panning. Defaults to true.

enablePan?: boolean

Whether or not pan is enabled. Defaults to true.

enabled?: boolean

Whether or not the widget is enabled, ie. responding to mouse input. Defaults to true.

events?: {
    maybeZoom?: Function;
    mousedown?: Function;
    mousemove?: Function;
    mouseup?: Function;
    pan?: Function;
    transformOrigin?: Function;
    zoom?: Function;
}

Optional map of event handlers

Type declaration

  • Optional maybeZoom?: Function

    Optional interceptor for zoom. Returning false prevents zoom from occurring.

  • Optional mousedown?: Function

    Optional function callback for mousedown event.

  • Optional mousemove?: Function

    Optional function callback for mousemove event.

  • Optional mouseup?: Function

    Optional function callback for mouseup event.

  • Optional pan?: Function

    Optional function callback for when pan changes.

  • Optional transformOrigin?: Function

    Optional function callback for transform origin change. This is given the [x,y] (in percent) of the new origin, and the [left, top] (in absolute values) of the canvas.

  • Optional zoom?: Function

    Optional function callback for when zoom changes.

filter?: Function

Optional filter that will be called on down event, with the event target and the event. Returning true from this function means the widget should respond to the event.

getOffset: ((el) => PointXY)

A function that can return the x,y location of the given element, relative to the origin of the canvas the pan zoom is controlling.

Type declaration

getOffsetRelativeToRoot: ((el) => PointXY)

A function that can return the x,y location of the given element, relative to the document origin

Type declaration

getSize: ((el) => Size)

Gets the size of some element

Type declaration

    • (el): Size
    • Parameters

      • el: Element

      Returns Size

idFunction: ((e) => string)

Function the widget can use to derive an ID for the given element.

Type declaration

    • (e): string
    • Parameters

      • e: Element

      Returns string

panDistance?: number

How far, in pixels, to pan on pan nudge. Defaults to 50 pixels.

panFilter?: ((el) => boolean)

Optional function which is called at the start of panning and can return false to reject pan starting.

Type declaration

    • (el): boolean
    • Parameters

      • el: Element

      Returns boolean

panWithMetaKey?: boolean

Defaults to false. When true, user must hold down meta key (ctrl on windows) to pan.

smartMinimumZoom?: boolean

NOT IMPLEMENTED. This is a placeholder for possible future functionality, which will mean that the lower zoom bound refers to a multiple of the content bounds, not the viewport.

viewportElement: Element

The element that will act as the viewport for the canvas.

Options for the wheel.

zoom?: number

Initial zoom for the widget. Defaults to 1.

zoomRange?: ZoomRange

Zoom range for the widget. Defaults to [0.05, 3].

Version :