ReaderViewAnnotationLayer

ReaderViewAnnotationLayers are used for creating and rendering ReaderViewAnnotations. Annotation layers are created using ReaderView.createAnnotationLayer and are rendered on top of publication content.

Each annotation layer will create an overlay element on top of each page in the ReaderView. 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.defaultAnnotationOptions.containerClassName = "my-container-class".

  2. Add the following CSS to the WebView by calling ReaderView.addCustomCss():

.colibrio-reader-view-annotation-layer--left-spread .my-container-class {
// My left spread styles.
}

Use ReaderViewAnnotationLayer.options to set the desired CSS styles for overlay elements. Use ReaderViewAnnotationLayer.defaultAnnotationOptions or ReaderViewAnnotation.options to set the desired CSS styles for the rendered annotation rectangles.

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

It is recommended to set "mix-blend-mode" to for example "multiply" in the ReaderViewAnnotationLayer.options.layerStyle to display text highlights.

Functions

Link copied to clipboard

Adds an instance of OnAnnotationClickListener to the layer.

Link copied to clipboard
Link copied to clipboard
abstract fun createAnnotation(locator: SimpleLocatorData, customData: Any? = null): ReaderViewAnnotation

Create a new annotation to this layer using a locator referencing publication content. Additionally one can pass in some customData that will be accessible from the annotation instance.

Link copied to clipboard

Create multiple annotation from a list of locators referencing publication content.

Link copied to clipboard
abstract fun destroyAllAnnotations()

Removes and destroys all ReaderViewAnnotation instances added to the layer.

Link copied to clipboard
abstract fun destroyAnnotation(annotation: ReaderViewAnnotation)

Removes and destroys an annotation previously added to the layer.

Link copied to clipboard

Removes an instance of OnAnnotationClickListener from the layer.

Link copied to clipboard

Properties

Link copied to clipboard

All annotations created with this layer.

Link copied to clipboard

Gets/sets the default options that will be used for newly created ReaderViewAnnotations with this layer.

Link copied to clipboard
abstract val destroyed: Boolean

Indicates if this annotation layer has been destroyed.

Link copied to clipboard

Gets/sets the options used by this annotation layer.

Link copied to clipboard
abstract var visible: Boolean

Gets/sets if this layer is visible or not. A newly created ReaderViewAnnotationLayer is visible by default.