What javascript works as expected in epub using iBooks?

I am writing a pop-up pop-up description of a footnote for epubs at the moment, and I'm disappointed with the lack of documentation available for javascript to work and not working inside epub using iBooks specifically.

In my experience, using jQuery, doing the basic show / hide of an element does work, but manipulating the DOM does not, and getting element positions is sketchy at best.

Has anyone worked with javascript on epub before and are willing to share best practices? Is it wise to use jQuery, or can you get more functionality using javascript for vanillin? Thanks!

+4
source share
2 answers

The vast majority of JS content works great on iBooks, including manipulating the DOM. However, with respect to the positions, the basic concept of positions is different in the e-book (although with the new iBooks 3.0 scrolling mode it looks more like a traditional web page), and you probably want to limit the position logic to determining whether something is happening or from the screen. If it is not on the screen, trying to scroll it by setting scollPos or something like that will not work well, if at all; instead, try navigating to the appropriate location with something like location.href="foo.xhtml#myanchor;

+3
source

I tried launching an HTML widget with jqPlot (http://www.jqplot.com/), a graphical jquery library, and it worked great on an iPad. You can check their source code.

+1
source

Source: https://habr.com/ru/post/1392802/


All Articles