Open yashspr opened 6 days ago
It's hard to say. Some ideas:
view.resolveCFI()
to get a range from the CFI. Then inspect the range and see whether it's correct, and what rects the browser returns when you call getClientRects()
. Compare the coordinates of these rects to view.renderer.start
. Either the it's picking the wrong rect (that is, a rect that doesn't really match the visual area of the target), or if it is using the right one, just isn't scrolling to it correctly.Thanks for the suggestions. Will debug and let you know
You were right, the coordinates of the range from the cfi were not matching with the current page. And also noticed something strange. The width of the iframe, and the width of its parent div dont match. In my case, the width of the iframe is ~8000px, the width of the parent div is ~10500px.
And when I scrolled the div#container
to position (0,0)
using scrollTo, there was just empty space. So, there is some issue with iframe's parent div's width which is creating empty space and affecting the pagination.
When the section initially loads, it is somehow scrolled to the right position, which is why next()
and prev()
work fine i believe.
No, that's expected. In order to slide out the section when transitioning to the next/previous section, there is one extra empty "page" on both sides of the section, which complicates things a little.
Hey John, first of all, thanks for building this amazing project. It is much better than epubjs.
Here is what i am trying to do:
relocate
event.What is happening? I am retrieving the saved cfi and using the
this.view.goTo()
method to go to that cfi position. But it doesn't take me to the right page. Its usually one or two pages behind.Here is a small snippet:
What I think is happening?
goTo
might be calculating the page to go to before the styles are loaded. The styles includes things like font size, font family, etc. which can affect the pagination.goTo
from the browser console after all the styles are loaded, it still fails.So I am not sure what is happening. Any help here is greatly apprecited. Thanks.