sesaparcours
    Preparing search index...

    Models the positions of the elements a given jsPlumb instance is tracking. Users of the API should not need to interact directly with a Viewport.

    Type Parameters

    • T extends { E: unknown }

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _bounds: Record<string, number>
    _elementMap: Map<string, ViewportElement<T["E"]>>
    _sortedElements: Record<string, [string, number][]>
    _transformedElementMap: Map<string, TranslatedViewportElement<T["E"]>>
    instance: JsPlumbInstance<T>

    Methods

    • Adds the element with the given id, with the given values for x, y, width, height and rotation. Any of these may be null.

      Parameters

      • id: string
      • x: number
      • y: number
      • width: number
      • height: number
      • rotation: number

      Returns ViewportElement<T["E"]>

    • Bind an event listener. This method can be used with a type parameter by call sites; although it's not necessary it can be helpful to use this to ensure you've thought about what the payload to your event handler is going to be.

      Type Parameters

      • T = any

      Parameters

      • event: string | String[]

        Name of the event(s) to bind to.

      • listener: (a: T, e?: any) => any

        Function to bind to the given event(s)

      • OptionalinsertAtStart: boolean

        Whether or not to insert this listener at the head of the listener queue. Defaults to false.

      Returns EventGenerator

    • Returns void

    • Fire the named event.

      Type Parameters

      • T

      Parameters

      • event: string

        Event to fire

      • Optionalvalue: T

        Value to pass to event handlers

      • OptionaloriginalEvent: Event

        Optional original event that caused this event to be fired.

      Returns any

    • Gets the height of the content managed by the viewport, taking any rotated elements into account.

      Returns number

    • Gets the width of the content managed by the viewport, taking any rotated elements into account.

      Returns number

    • Get all elements managed by the Viewport.

      Returns Map<string, ViewportElement<T["E"]>>

    • Gets all listeners for the given named event.

      Parameters

      • forEvent: string

      Returns any[]

    • Gets the position of the element. This returns both the original position, and also the translated position of the element. Certain internal methods, such as the anchor calculation code, use the unrotated position and then subsequently apply the element's rotation to any calculated positions. Other parts of the codebase - the Toolkit's magnetizer or pan/zoom widget, for instance - are interested in the rotated position.

      Parameters

      • id: string

      Returns ViewportElement<T["E"]>

    • Gets the leftmost point of the content managed by the viewport, taking any rotated elements into account.

      Returns number

    • Gets the topmost of the content managed by the viewport, taking any rotated elements into account.

      Returns number

    • Returns whether or not the viewport is empty.

      Returns boolean

    • Returns whether not event firing is currently suspended

      Returns boolean

    • Returns void

    • Update the size/offset of the element with the given id, and adjust viewport bounds.

      Parameters

      • elId: string
      • OptionaldoNotRecalculateBounds: boolean

        If true, the viewport's bounds won't be recalculated after the element's size and position has been refreshed.

      Returns ViewportElement<T["E"]>

    • Creates an empty entry for an element with the given ID.

      Parameters

      • id: string
      • OptionaldoNotRecalculateBounds: boolean

        If true, the viewport's bounds won't be recalculated after the element has been registered.

      Returns ViewportElement<T["E"]>

    • Remove the element with the given ID from the viewport.

      Parameters

      • id: string

      Returns void

    • Clears the internal state of the viewport, removing all elements.

      Returns void

    • Rotates the element with the given id, recalculating bounds afterwards.

      Parameters

      • id: string
      • rotation: number

      Returns ViewportElement<T["E"]>

    • Sets the [x,y] position of the element with the given ID, recalculating bounds.

      Parameters

      • id: string
      • x: number
      • y: number

      Returns ViewportElement<T["E"]>

    • Sets the size of the element with the given ID, recalculating bounds.

      Parameters

      • id: string
      • w: number
      • h: number

      Returns ViewportElement<T["E"]>

    • Sets whether not event firing is currently suspended

      Parameters

      • val: boolean

      Returns void

    • Parameters

      • event: string
      • value: unknown
      • OptionaloriginalEvent: Event

      Returns boolean

    • Run the given function without firing any events.

      Parameters

      Returns void

    • Returns void

    • Unbind the given event listener, or all listeners. If you call this method with no arguments then all event listeners are unbound.

      Parameters

      • OptionaleventOrListener: string | Function

        Either an event name, or an event handler function

      • Optionallistener: Function

        If eventOrListener is defined, this is the event handler to unbind.

      Returns EventGenerator

    • Updates the element with the given id. Any of the provided values may be null, in which case they are ignored (we never overwrite an existing value with null).

      Parameters

      • id: string
      • x: number
      • y: number
      • width: number
      • height: number
      • rotation: number
      • OptionaldoNotRecalculateBounds: boolean

        Defaults to false. For internal use. If true, does not update viewport bounds after updating the element.

      Returns ViewportElement<T["E"]>

    • Parameters

      • entries: {
            height: number;
            id: string;
            rotation: number;
            width: number;
            x: number;
            y: number;
        }[]

      Returns void