Request

Response

    UI

    Autodesk.Viewing.UI.DockingPanel

    new DockingPanel(parentContainer,id,title,options)

    UI panel that is movable and resizable within the bounds of its parent container.

    Parameters

    Expand all
    parentContainer*
    HTMLElement
    The container for this panel.
    id*
    string
    The id to assign this panel.
    title*
    string
    The title of this panel.
    options
    object
    An optional dictionary of options.
    localizeTitle
    boolean
    When true, localization is attempted for the given title.
    * Required

    Examples

    // Example of a simple DockingPanel that displays the given content.
      // The titlebar and move behavior are overridden in initialize(), which also
      // creates a custom close button.
      //
      SimplePanel = function(parentContainer, id, title, content, x, y)
      {
          this.content = content;
          Autodesk.Viewing.UI.DockingPanel.call(this, parentContainer, id, '');
    
          // Auto-fit to the content and don't allow resize.  Position at the coordinates given.
          //
          this.container.style.height = "auto";
          this.container.style.width = "auto";
          this.container.style.resize = "none";
          this.container.style.left = x + "px";
          this.container.style.top = y + "px";
      };
    
      SimplePanel.prototype = Object.create(Autodesk.Viewing.UI.DockingPanel.prototype);
      SimplePanel.prototype.constructor = SimplePanel;
    
      SimplePanel.prototype.initialize = function()
      {
          // Override DockingPanel initialize() to:
          // - create a standard title bar
          // - click anywhere on the panel to move
          // - create a close element at the bottom right
          //
          this.title = this.createTitleBar(this.titleLabel || this.container.id);
          this.container.appendChild(this.title);
    
          this.container.appendChild(this.content);
          this.initializeMoveHandlers(this.container);
    
          this.closer = document.createElement("div");
          this.closer.className = "simplePanelClose";
          this.closer.textContent = "Close";
          this.initializeCloseHandler(this.closer);
          this.container.appendChild(this.closer);
      };
    
    Show More

    Methods

    addEventListener(target,eventId,callback)

    Adds an event listener to a given target that has an addEventListener(event, callback) API. These event listeners are tracked by the DockingPanel and are automatically removed on uninitialize.

    Parameters

    target*
    object
    The target that will fire the event.
    eventId*
    string
    The event to be listened to.
    callback*
    function
    The callback to execute when the event is fired.
    * Required

    addVisibilityListener(callback)

    Adds a callback to call when this DockingPanel changes visibility.

    Parameters

    callback*
    function
    A function that takes in a single boolean parameter indicating the current visibility state.
    * Required

    createCloseButton()

    Creates a close button to add to this DockingPanel. When clicked, this DockingPanel is hidden. Call this method during initialize() if a standard close button is desired, and then add it to an existing container.

    Returns

    TypeDescription
    HTMLElement The created close button.

    createScrollContainer(options)

    Creates a scroll container element to add to this DockingPanel. Call this method during initialize() if a scroll container is needed. The function will create the scroll container and make it available via the “scrollContainer” property of the DockingPanel.

    Parameters

    Expand all
    options
    object
    An optional dictionary of options.
    left
    boolean
    When true, the scrollbar appears on the left.
    heightAdjustment
    number
    The scroll container height is 100% of the panel minus the height adjustment. Provide a value to account for other elements in the panel like a title bar.
    marginTop
    number
    The marginTop setting for the scroll container’s CSS style, in pixels.

    createTitleBar(title)

    Creates a title bar element to add to this DockingPanel. Call this method during initialize() if a standard title bar is desired, and then add it to an existing container.

    Parameters

    title*
    string
    The text to use in the title bar.
    * Required

    Returns

    TypeDescription
    HTMLElement The created title bar.

    getContainerBoundingRect()

    Returns the parent’s container bounding rectangle.

    Returns

    TypeDescription
    ClientRect Bounding rectangle of the parent.

    getContentSize()

    Override this method to return the width and height to use when resizing the panel to the content.

    Returns

    TypeDescription
    object {height: number, width: number}.

    initialize()

    Creates the sub-elements of this DockingPanel. Override this in derived classes. The default implementation is to create a title bar with the title or id provided in the constructor. The title bar also acts as the move handler for the DockingPanel. Finally, a close button is added to the top right corner.

    initializeCloseHandler(closer)

    Initializes the given HTMLDomElement as the close handle for this DockingPanel. When this element is clicked, this DockingPanel is hidden.

    Parameters

    closer*
    HTMLElement
    The DOM element that will act as the close handle.
    * Required

    initializeMoveHandlers(mover)

    Initializes the given HTMLDomElement as the move handle for this DockingPanel. When this element is clicked and dragged, this DockingPanel is moved.

    Parameters

    mover*
    HTMLElement
    The DOM element that will act as the move handle.
    * Required

    isVisible()

    Gets the new visibility state of this DockingPanel.

    Returns

    TypeDescription
    boolean Whether or not the panel is visible.

    onEndMove(event,endX,endY)

    Override this event to be notified when this panel ends a move operation.

    Parameters

    event*
    MouseEvent
    The mouseup event.
    endX*
    number
    The ending x position of the panel in pixels.
    endY*
    number
    The ending y position of the panel in pixels.
    * Required

    onMove(event,currentX,currentY)

    Override this to be notified when this panel is moved. Note, do not forget to call this base class method in the overriding method.

    Parameters

    event*
    MouseEvent
    The mousemove event.
    currentX*
    number
    The current x position of the panel in pixels.
    currentY*
    number
    The current y position of the panel in pixels.
    * Required

    onStartMove(event,startX,startY)

    Override this event to be notified when this panel begins a move operation.

    Parameters

    event*
    MouseEvent
    The mousedown event.
    startX*
    number
    The starting x position of the panel in pixels.
    startY*
    number
    The starting y position of the panel in pixels.
    * Required

    onTitleClick(event)

    Override this method to be notified when the user clicks on the title.

    Parameters

    event*
    Event
    * Required

    onTitleDoubleClick(event)

    Override this method to be notified when the user double-clicks on the title.

    Parameters

    event*
    Event
    * Required

    removeEventListener(target,eventId,callback)

    Removes an existing event listener added using DockingPanel.addEventListener.

    Parameters

    target*
    object
    The target with the event listener.
    eventId*
    string
    The id of the event being listened to.
    callback*
    function
    The callback executed when the event is fired.
    * Required

    Returns

    TypeDescription
    boolean True if the listener was removed successfully; false otherwise.

    resizeToContent(options)

    Resizes the panel to the current content. Currently this only works on height.

    Parameters

    Expand all
    options
    object
    An optional dictionary of options.
    maxHeight
    number
    The maximum height to resize this panel.

    setTitle(text,options)

    Sets the title for this panel.

    Parameters

    Expand all
    text*
    string
    The title for this panel.
    options
    Object
    An optional dictionary of options.
    localizeTitle
    boolean
    When true, localization is attempted for the given text.
    * Required

    setVisible(show)

    Sets the new visibility state of this DockingPanel.

    Parameters

    show*
    boolean
    The desired visibility state.
    * Required

    uninitialize()

    Performs any clean up necessary. This can include disconnecting UI elements, unregistering event callbacks, etc.

    visibilityChanged()

    Notification that visibility has been changed by external sources.

     
    Version 2