Options
All
  • Public
  • Public/Protected
  • All
Menu

Annotation layers allow you to render content on top of the publication content. This can for example be used to highlight search results, or highlight items from a publication's Table of Contents.

You can create a new annotation layer using ReaderView.createAnnotationLayer('someName');

Each annotation layer will create an overlay element on top of each page in the ReaderView. Added annotations will render as rectangles into these overlay elements.

The ReaderViewAnnotationLayer DOM structure is as follows:

- `<div class="colibrio-reader-view-annotation-layer">` which is rendered on top of all pages.
- `<div class="colibrio-reader-view-annotation-container">` which is rendered for each annotation.
- One or more <div> elements, if the annotation refers to a range, or
- One <div> element, if the annotation refers to a position in the content.

Additionally, the ReaderViewAnnotationLayer element (<div class="colibrio-reader-view-annotation-layer">) will also have one of the following classes when displayed in a spread:

  • colibrio-reader-view-annotation-layer--left-spread if the element is in the left spread slot.
  • colibrio-reader-view-annotation-layer--right-spread if the element is in the right spread slot.

For example, to style a <div class="colibrio-reader-view-annotation-container"> element depending on which side of the spread it is rendered on:

  1. Set a custom class name for containers in this layer. For example layer.setDefaultAnnotationOptions({ containerClassName: 'my-container-class' }).
  2. Add the following CSS to your app's stylesheet:
    .colibrio-reader-view-annotation-layer--left-spread .my-container-class {
    // My left spread styles.
    }

Use ReaderViewAnnotationLayer.setOptions() to set the desired CSS styles for overlay elements. Use ReaderViewAnnotationLayer.setDefaultAnnotationOptions() or ReaderViewAnnotation.setOptions() to set the desired CSS styles for the rendered annotation rectangles.

There is no styling on these elements by default, (except positioning styles).

It is recommended to use "mix-blend-mode" with for example "multiply" in the layerStyle to display text highlights. For example:

annotationLayer.setLayerOptions({
layerStyle: {
'mix-blend-mode': 'multiply'
}
});

annotation.setOptions({
rangeStyle: {
'background-color': 'violet'
}
});

Use 'opacity' instead of 'mix-blend-mode' if the latter is not supported by the browser. You can check browser support by using RuntimePlatform.isCssDeclarationSupported('mix-blend-mode', 'multiply')

Type parameters

  • T = any

Hierarchy

Index

Methods

addEngineEventListener

createAnnotation

  • Create a new ReaderViewAnnotation in this layer using the specified locator.

    Type parameters

    • U

    Parameters

    Returns IReaderViewAnnotation<U>

createAnnotations

destroyAllAnnotations

  • destroyAllAnnotations(): void
  • Removes and destroys all ReaderViewAnnotation instances added to this layer.

    Returns void

destroyAnnotation

  • Destroys a ReaderViewAnnotation created by this layer. Throws an error if the ReaderViewAnnotation was not created with this layer.

    Parameters

    Returns void

getAnnotations

getDefaultAnnotationOptions

getEngineEventListeners

getLayerOptions

getName

  • getName(): string
  • Get the name of this annotation layer.

    Returns string

getReaderView

  • Get the associated IView instance.

    Returns IReaderView

isDestroyed

  • isDestroyed(): boolean
  • If this annotation layer has been destroyed. All methods are no-ops if the layer is destroyed.

    Returns boolean

isVisible

  • isVisible(): boolean
  • If this annotation layer is currently visible. A newly created layer is visible by default.

    Returns boolean

removeEngineEventListener

setDefaultAnnotationOptions

  • Set default options for annotations. These default options applies for all ReaderViewAnnotations that have no options assigned to them.

    Parameters

    Returns void

setLayerOptions

setVisible

  • setVisible(visible: boolean): void
  • Set if this annotation layer should be visible or not. A newly created ReaderViewAnnotationLayer is visible by default.

    Parameters

    • visible: boolean

    Returns void

Generated using TypeDoc