PrizmDoc Viewer v13.19 - Updated
API Reference / Viewer Control / Namespace: PCCViewer / Class: ThumbnailControl
In This Topic
    Class: ThumbnailControl
    In This Topic

    PCCViewer. ThumbnailControl

    The ThumbnailControl is a viewer for the thumbnails associated with a document. It is associated with a PCCViewer.ViewerControl object at initialization, and will display the thumbnails of the document being viewed in that ViewerControl.

    Constructor

    new ThumbnailControl(domElement, viewerControl)

    Creates a new PCCViewer.ThumbnailControl object.

    Parameters:

    Name Type Description
    domElement HTMLElement

    The DOM element in which to embed the ThumbnailControl.

    viewerControl PCCViewer.ViewerControl

    The ViewerControl object for which to display thumbnails.

    See:

    Throws:

    If either of the parameters is undefined or an invalid value.

    Type
    Error

    Members

    (static, readonly) EventType :string

    The EventType enumeration defines event types known to PCCViewer.ThumbnailControl.

    Note: This enumeration is for convenience for API developers. Instead of using this enumeration, you can pass string values of the eventType (enumeration values)

    Type:

    • string

    Properties:

    Name Description
    PageSelectionChanged : string

    Event is triggered when the collection of selected thumbnails changes.

    Augmented properties of the PCCViewer.Event object for this event:

    • pageNumbers {Array.<number>} The currently selected page numbers.
    See:

    selectedPages :Array.<number>|number

    An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

    Gets and sets the selected pages in the Thumbnail Control.

    Type:

    • Array.<number> | number
    See:

    (readonly) viewerControl :PCCViewer.ViewerControl

    An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

    Gets the PCCViewer.ViewerControl object associated with this ThumbnailControl.

    Type:

    See:

    (readonly) visiblePages :Array.<number>

    An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

    Gets the page numbers of the pages currently visible in the ThumbnailControl view.

    Type:

    • Array.<number>
    See:

    Methods

    destroy()

    This method will remove the thumbnails from the original HTMLElement and return it to its previous state. It will destroy all of the thumbnails and release their resources. The ThumbnailControl can no longer be used after calling this method, and a new one will need to be created to continue viewing thumbnails.

    getSelectedPages() → {Array.<number>}

    Gets the currently selected thumbnails.

    See:

    Returns:

    The page numbers of the selected thumbnails.

    Type
    Array.<number>

    getViewerControl() → {PCCViewer.ViewerControl}

    Gets the PCCViewer.ViewerControl object associated with this ThumbnailControl.

    Returns:

    The ViewerControl associated with this ThumbnailControl.

    Type
    PCCViewer.ViewerControl

    getVisiblePages() → {Array.<number>}

    Gets the page numbers of the pages currently visible in the ThumbnailControl view. This will include pages that are only partly visible, as well as pages that are not yet fully loaded but part of their placeholder is visible.

    Returns:

    An array of page numbers.

    Type
    Array.<number>

    off(eventType, handler) → {PCCViewer.ThumbnailControl}

    Unsubscribe an event handler from a specified event type.

    Typically, an event is unsubscribed when you no longer want further notification of the event.

    Parameters:

    Name Type Description
    eventType string

    A string specifying the event type. See PCCViewer.ThumbnailControl.EventType for a list and description of all supported events.

    handler PCCViewer.Event~eventHandler

    A function that was attached previously to the ViewerControl.

    Note: This must be the same function object previously passed to PCCViewer.ThumbnailControl#on. It cannot be an different object that is functionally equivalent.

    See:

    Returns:

    The ThumbnailControl object on which this method was called.

    Type
    PCCViewer.ThumbnailControl

    on(eventType, handler) → {PCCViewer.ThumbnailControl}

    Subscribe an event handler to an event of a specified type.

    Parameters:

    Name Type Description
    eventType string

    A string that specifies the event type. This value is case-insensitive. See PCCViewer.ThumbnailControl.EventType for a list and description of all supported events.

    handler PCCViewer.Event~eventHandler

    A function that will be called whenever the event is triggered.

    See:

    Returns:

    The ThumbnailControl object on which this method was called.

    Type
    PCCViewer.ThumbnailControl

    reflow() → {PCCViewer.ThumbnailControl}

    This method will calculate the size of a thumbnail based on the defined CSS, and will fit each individual page element to the thumbnail container. This method can also be called to programmatically trigger the loading of newly visible pages in cases where the thumbnail view either dynamically or manually changes size, or the thumbnails themselves change size.

    Note: This method can be a bit expensive, so it is best to debounce it from any event that triggers a thumbnail resize, such as a window resize.

    Returns:

    The ThumbnailControl object on which this method was called.

    Type
    PCCViewer.ThumbnailControl

    Example

    // First, get the thumbnailControl
    
    // Create a resize function
    var resize = function(){
        thumbnailControl.reflow();
    };
    
    // Create a debounce function
    var debounceTimer;
    var debounceEvent = function(){
        if (debounceTimer) {
            clearTimeout(debounceTimer);
            debounceTimer = undefined;
        }
    
        debounceTimer = setTimeout(resize, 300);
    };
    
    // Add the debounced function to the resize event
    window.onresize = debounceEvent;
    

    scrollTo(pageNumber, optionsopt) → {PCCViewer.ThumbnailControl}

    Scrolls to a specified page. By default, this will be done using the minimum amount of scrolling, so pages that are above the current view will be scrolled to appear at the top of the view, and pages below the current view will be scrolled to appear at the bottom. This can be overridden with the options parameter.

    Parameters:

    Name Type Attributes Description
    pageNumber number

    The page to scroll to.

    options Object <optional>

    Provide options to the scroll method to indicate desired behavior.

    Properties
    Name Type Attributes Description
    forceAlignTop boolean <optional>

    Overrides the default scrolling behavior, and forces the specified page to always be scrolled to the top of the view.

    Throws:

    If the pageNumber is not within the range of the page count for the specified document.

    Type
    Error

    Returns:

    The ThumbnailControl object on which this method was called.

    Type
    PCCViewer.ThumbnailControl

    setSelectedPages(pageNumbers) → {PCCViewer.ThumbnailControl}

    Sets the currently selected thumbnails.

    Parameters:

    Name Type Description
    pageNumbers Array.<number> | number

    The page number (or numbers) to select. The first selected page will automatically be scrolled into view if it is not already visible. See PCCViewer.ThumbnailControl#scrollTo for more details on scrolling to a page.

    See:

    Throws:

    • If the pageNumbers parameter is undefined, or not a number or array of numbers.

      Type
      Error
    • If any of the numbers defined in pageNumbers is out of range of the document page count.

      Type
      Error

    Returns:

    The ThumbnailControl object on which this method was called.

    Type
    PCCViewer.ThumbnailControl

    Documentation generated by JSDoc 3.3.3 on Wed Jan 19 2022 03:44:39 GMT-0500 (Eastern Standard Time)