joseph / Monocle

A silky, tactile browser-based ebook JavaScript library.
http://monocle.inventivelabs.com.au
MIT License
743 stars 200 forks source link

Node to percent calculation is not giving expected page no #264

Open nsanthakumar86 opened 8 years ago

nsanthakumar86 commented 8 years ago

I have tried to show epub book by monocle in android app. It has muliple xhtml file. I am facing problem while navigating to selected section by selector. The below function has been used for navigation.

function goToSelector(cmptId, selector) { window.reader.moveTo({ componentId: cmptId, selector: selector });

  }

we are passing component id as file:///data/data/com.xxx.yyy/epubfolder/book1.xhtml selector: #P009...;

In this flow, It is executing the querySelector() method by given selector(#P00044.....) in whole window and getting node( I printed this node innnerHTML in cosole, It is correct node of our selection id only).

And then it is passing this node to pageForSelector() method to get the page no and inside this method it is calculating percent of locus.

Now locus has component id and locus percent using by those values percentToPageNumber() method returning page no.

It is loading this page no only but its wrong in mobile.

But i have executed same xhtml file with locus-selection test app. In desktop it is working but not in app.

Please help me to resolve this issue.

Note: This Problem is happening only for page is too big. It means it divided as more than 5 sections.

Thanks, Santhakumar.N