based on @johnfactotum comments I got to the following code https://github.com/futurepress/epub.js/issues/759#issuecomment-1399499918 which worked well for me
After checking https://github.com/futurepress/epub.js/issues/997#issuecomment-552321080 and https://github.com/futurepress/epub.js/issues/986#issuecomment-538716885 I come up with the following code which works for me in most cases
function flatten(chapters: any) {
return [].concat.apply([], chapters.map((chapter: NavItem) => [].concat.apply([chapter], flatten(chapter.subitems))));
}
export function getCfiFromHref(book: Book, href: string) {
const [_, id] = href.split('#')
const section = book.spine.get(href)
const el = (id ? section.document.getElementById(id) : section.document.body) as Element
return section.cfiFromElement(el)
}
export function getChapter(book: Book, location: Location) {
const locationHref = location.start.href
let match = flatten(book.navigation.toc)
.filter((chapter: NavItem) => {
return book.canonical(chapter.href).includes(book.canonical(locationHref))
}, null)
.reduce((result: NavItem|null, chapter: NavItem) => {
const locationAfterChapter = EpubCFI.prototype.compare(location.start.cfi, getCfiFromHref(book, chapter.href)) > 0
return locationAfterChapter ? chapter : result
}, null);
return match;
};
I added thumbStyle
, thumbSize
, trackHeight
props to the Props Table in Readme.md
Just check Props Table in the readme.md file.
you should find thumbStyle
, thumbSize
, trackHeight
rows.
Closed because those props are only available for web. check https://github.com/callstack/react-native-slider/issues/92#issuecomment-1380176200
@Sharcoux Didn't notice that. I'm closing the PR. Thank you
Update README.md
Co-authored-by: Taym Haddadi haddadi.taym@gmail.com
After taking a look at the Code, I've found that we thumbStyle
, thumbSize
, trackHeight
properties that are not mentioned in Readme.md Doc. maybe this could help.
Here is a PR containing README.md updates #481
I added thumbStyle
, thumbSize
, trackHeight
props to the Props Table in Readme.md
Just check Props Table in the readme.md file.
you should find thumbStyle
, thumbSize
, trackHeight
rows.
add thumbStyle, thumbSize, trackHeight props to Readme.md