Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents a location within a ReaderPublication and methods to extract information related to that location. A ContentLocation can be a position in the publication content, or a range across publication content.

ContentLocations are provided by all APIs in the framework that reference positions and ranges within ReaderPublications. Some example of APIs that provide ContentLocations are:

  • ReaderView.getVisibleRange()
  • EngineEvents,
  • SyncMediaTimeline
  • etc.

In contrast to UnresolvedContentLocation, a ContentLocation knows its position within the publication content and can thereby be used to compare and sort ContentLocation instances synchronously. The following methods are synchronous in ContentLocation but not in UnresolvedContentLocation:

  • contains()
  • equals()
  • intersects()
  • isAfter()
  • isBefore()

If you only need to get the ReaderDocument for a Locator, ReaderPublication.fetchUnresolvedContentLocation() should be preferred as it is more performant than ReaderPublication.fetchContentLocation().

Hierarchy

  • IContentLocation

Index

Methods

collapseToEnd

  • If this ContentLocation represents a range, it creates a new ContentLocation by collapsing to its end position. If this ContentLocation does not represent a range, the instance itself is returned.

    Returns IContentLocation

collapseToStart

  • If this ContentLocation represents a range, it creates a new ContentLocation by collapsing to its start position. If this ContentLocation does not represent a range, the instance itself is returned.

    Returns IContentLocation

contains

  • Check if the passed ContentLocation is equal to this one, or is contained inside this ContentLocation.

    Parameters

    Returns boolean

createRangeTo

  • Creates a new ContentLocation representing the range from the start of this instance to the end of endLocation.

    Parameters

    Returns IContentLocation

equals

  • Check if this ContentLocation target exactly the same content as the passed ContentLocation.

    Parameters

    Returns boolean

fetchContentBlockTargets

  • Fetch the content blocks that corresponds to the ContentLocation.

    Parameters

    • fetchMode: ContentBlockTargetFetchMode

      Determines whether it should include the ContentBlock before or after the location if the ContentLocation start or end, targets content in between two ContentBlocks.

    Returns Promise<IContentBlockTarget[]>

fetchContentResolver

  • Fetch a IContentLocationContentResolver for the ContentLocation. The IContentLocationContentResolver is used for getting publication content related with this ContentLocation.

    Returns Promise<IContentLocationContentResolver>

fetchNavigationItemReferences

  • Fetch references to the ReaderPublicationNavigationItems related with this ContentLocation. This can for example be used to get the current "Table of Contents" items that are currently visible in the ReaderView.

    Example:

    readerView.getReadingPosition().fetchNavigationItemReferences({
    collectionTypes: [NavigationCollectionType.TOC], // Only fetch items from the "Table of contents" collection.
    greedy: true, // For TOC, specify `greedy: true`, see IFetchNavigationItemReferencesOptions for more information.
    })

    Parameters

    Returns Promise<IFetchNavigationItemReferencesResult>

getLocator

  • Get the Locator that was used to create this instance.

    Returns Locator

getReaderDocuments

  • Get the ReaderDocuments that this ContentLocation points to.

    Returns IReaderDocument[]

getReaderPublication

intersects

  • Check if this ContentLocation intersects with another ContentLocation.

    Parameters

    Returns boolean

isAfter

  • Check if this ContentLocation is strictly after the passed ContentLocation. Returns false if the locations are intersecting.

    Parameters

    Returns boolean

isBefore

  • Check if this ContentLocation is strictly before the passed ContentLocation. Returns false if the locations are intersecting.

    Parameters

    Returns boolean

isRange

  • isRange(): boolean
  • Returns true if this ContentLocation represents a range.

    Returns boolean

toJSON

  • Return a serializable version of the Locator that was used to create this instance. This is the same as calling getLocator().toJSON().

    Returns ISimpleLocatorData

Generated using TypeDoc