GithubHelp home page GithubHelp logo

Comments (5)

fchasen avatar fchasen commented on May 14, 2024

Updated EPUBJS.Renderer.prototype.isElementVisible

Thanks!

from epub.js.

panurge-ws avatar panurge-ws commented on May 14, 2024

I'm sorry, but after running some tests, also the solution suggested above is not working.
With left <= width, if we have a page with an element that ends exactly at the end of the page/column, the first visible becomes the fist in the next page....

The problem occurs within an iPhone screen: it seems with small page (spreadWith) width it fails to catch the right first visible element. I'm looking for some other solutions.
(Thanks for your work)

from epub.js.

bielskij avatar bielskij commented on May 14, 2024

Hi,
I've noticed the same issue on some books rendered on small screens.

The issue is reproductible with a google chrome browser with reduced size of div where epubjs renders a book.

I've found that CFI attached to the pageMap of chapter contains incorrect endOffset value in case of callapsed paragraph/span. The CFI points to the last word on previous page, so finally the function generateRangeFromCfi() generates range that left position is smaller than pageSize. Function getPageNumberByRect() called by gotoCfi() with range returned from generateRangeFromCfi() using extra function Math.floor() designates incorrect page number (it points to the previous one).

I'm not able to provide the best solution but I think that the process of generating page CFI should be fixed - it should return offset from the first word on the next page, not offset of the last word on previous page as is now.

from epub.js.

bielskij avatar bielskij commented on May 14, 2024

Hi,

I've deeper investigated the issue and I've already got a simple solution. The issue was related to bad working CFI generator mechanism for DOM element. It uses string.indexOf method to split text into words by space character. As there could be other characters that can break the line, they should be proprly handled.

You can find fix in my forked branch, commit 287cbcd.

from epub.js.

fchasen avatar fchasen commented on May 14, 2024

Fix is now in master, thanks again @bielskij

from epub.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.