Class ViewBox

Scales a single child element to fill the available space without resizing it. This control reacts to changes in the size of the container as well as changes in size of the child element. For example, a media query may result in a change in aspect ratio.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(element?: HTMLElement, options?: any): ViewBox

Initializes a new instance of the ViewBox control.

constructor

Parameters

  • element?: HTMLElement optional

    The DOM element that functions as the scaling box. This element fills 100% of the width and height allotted to it.

  • options?: any optional

    The set of options to be applied initially to the ViewBox control. There are currently no options on this control, and any options included in this parameter are ignored.

Returns

ViewBox

Properties

public element: HTMLElement

Gets the DOM element that functions as the scaling box.

Methods

public addEventListener(eventName: string, eventHandler: Function, useCapture?: boolean)

Adds an event handler for the specified event.

Parameters

  • eventName: string

    The name of the event to handle.

  • eventHandler: Function

    The event handler function to associate with the event.

  • useCapture?: boolean optional

    Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase.

public dispose()

Releases resources held by this ViewBox. Call this method when the ViewBox is no longer needed. After calling this method, the ViewBox becomes unusable.

public forceLayout()

Forces the ViewBox to update its layout. Use this function when making the ViewBox visible again after its style.display property had been set to "none".

public removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean)

Removes an event handler that the addEventListener method registered.

Parameters

  • eventName: string

    The name of the event that the event handler is registered for.

  • eventCallback: Function

    The event handler function to remove.

  • useCapture?: boolean optional

    Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler.