Navigator

interface Navigator

Base interface for a navigator rendering a publication.

A few points to keep in mind when implementing this interface:

  • The navigator should have a minimal UX and be focused only on browsing and interacting with the document. However, it offers a rich API to build a user interface around it.

  • The last read page (progression) should not be persisted and restored by the navigator. Instead, the reading app will save the Locator reported by the navigator in currentLocator, and provide the initial location when creating the navigator.

  • User accessibility settings should override the behavior when needed (eg. disabling animated transition, even when requested by the caller).

  • The navigator is the single source of truth for the current location.

  • The navigator should only provide a minimal gestures/interactions set. For example, scrolling through a web view or zooming a fixed image is expected from the user. But additional interactions such as tapping/clicking the edge of the page to skip to the next one should be implemented by the reading app, and not the navigator.

Inheritors

Types

Link copied to clipboard
interface Listener

Properties

Link copied to clipboard
abstract val currentLocator: StateFlow<Locator>

Current position in the publication. Can be used to save a bookmark to the current position.

Functions

Link copied to clipboard
abstract fun go(link: Link, animated: Boolean = false): Boolean

Moves to the position in the publication targeted by the given link.

abstract fun go(locator: Locator, animated: Boolean = false): Boolean

Moves to the position in the publication corresponding to the given Locator.