I am currently using @sbrighiu/epubjs-rn
in react native for epub
file reader.
In the documentation the onLocationChange
function definition is as follow:
onLocationChange: Function called on every page change, reports current CFI
src: "https://s3.amazonaws.com/epubjs/books/moby-dick.epub",
<Epub
flow="paginated"
ref={(ref) => this.readerRef = ref}
src={this.state.src}
flow={this.state.flow}
location={this.state.location}
onLocationChange={(visibleLocation, cfi) => {
this.onLocationChange(visibleLocation, cfi)
}}
onLocationsReady={(locations) => {
console.log("onLocationsReady", locations);
}}
onReady={(book) => {
this.onReady(book)
}}
onPress={
(cfi, position, rendition) => {
this.toggleBars();
console.log("onPress", cfi);
this.setState({
cuurentLocation: cfi
})
}}
onSelected={(cfiRange, rendition) => {
rendition.highlight(cfiRange, {});
}}
onMarkClicked={(cfiRange, data, rendition) => {
rendition.unhighlight(cfiRange);
}}
origin={this.state.origin}
onError={(message) => {
console.log("EPUBJS-Webview", message);
}}
/>
onLocationChange = (visibleLocation, cfi) => {
console.log("visibleLocation", visibleLocation)
console.log("cfi", cfi)
this.setState({ visibleLocation: visibleLocation });
}
Unfortunately, as the image above, onLocationChange function doesn't return cfi.
only onPress(), onDlbPress(), onLongPress() functions return cfi: Is there any other option to get the current page's cfi ? OR Can you suggest an option to bookmark a specific page ?