1

I've started working on a "choose your own adventure" book, for which it seems epub is well-suited. The choice at the end of a section are mere href links to the sections that are the consequences of those choices.

However, especially on a phone, one can simply swipe to the next page rather than making a choice. This occurs accidentally, and since none of these are labeled with page numbers like in a real book, it can be easy to lose your place. Is there a way to disable swiping to the next page (xhtml file) in version 3? I'm not even entirely sure what this functionality might look like... maybe some xml weirdness in the metadata.opf file?

I'm having alot of trouble even figuring out which keywords I need to search for, so any help is appreciated.

epub format does include a "linear='no'" attribute in the spine (part of the metadata.opf file). It seems like (at one time) it might have been meant for a feature similar to this, in that it marks a xhtml file as being outside the linear scope of the book... you can't get to such a page by turning the pages at all.

However, as implemented in Apple Books and other epub apps, it is unusable for a "choose your own adventure"-type book. In Apple Books, clicking/tapping on a (choice) link opens a sort of dialog with that page's content and a "DONE" button below the content. It seems they have purposed this feature for some sort of endnotes/footnotes/figures functionality. I think this is in error on their part, but it does not matter much whether I am correct... if they do it, then it's unusable for what I want to do (even if some other app gets it right).

1
  • I finally found the linear="no" spine attribute, which sounds like what I might want. However, having tested it on iBooks (the first app I tend to test with, it's the quickest in that I don't have to airdrop it to my phone), and it sucks. Clicking on a link does flip through to that page, but pops up some sort of obnoxious hover window with a "done" button on it. Reading the spec, I can't help but think that Apple is just wrong in their interpretation. But wrong or right, it makes this particular feature unusable.
    – John O
    Commented Jul 7, 2023 at 20:51

1 Answer 1

1

One solution:

A. Make it as a CSS/JS onLoad page event full screen overlay. See example that someone did at (though it's not for an epub it should work) ....
StackOverflow article

B. Make that particular epub "web links page" as an independent page separate from the other storyline stuff leading up to it.

C. Plus code to prevent forward swiping such as using touch-action:none and overflow:hidden functionality in CSS body/html.

Other factors to consider:

  1. Epubs have a sidebar TOC and other secondary navigational links (such as guides); a user may encounter that 'frozen' page then resort to opening a sidebar TOC up and going to another page.
  2. Matching it all with your specific online market (eBook readers that allow javascript or only allow CSS code).

Apple Books example epub is set in chapters etc. Yet in your instance perhaps breaking it into "sections" will allow you to point each section of the story into any one of multiple different directions you want the storyline to go.

Another viable option: Jump-to anchor link

Place this in page (use a new ID per each link) where you want the person to have the option to click and have the story go certain 'other' directions as a choice of options for the reader:

<a href="#anchor1">Pick Option A</a>

<a href="#anchor2">Pick Option B</a>

Place these lower down in your page somewhere in the place where the new version of the story takes off into a new direction. The upper links will jump to:

<a id="anchor1"></a>

<a id="anchor2"></a>

Or much better for compilation, jump to another page:

<a href="../text/section-10.xhtml#anchor1"></a>

<a href="../text/section-12.xhtml#anchor2"></a>

Links explaining and showing the process: w3Docs example

W3Docs explanation

This would work ideally in a multi-section epub because in a multi-page epub you can keep the story line independent of the other pages for the remainder of the plot. When I say 'page' I merely mean the internal epub is setup with a whole string of html documents, none of which are visible to the end reader. Thus, setup the epub:

section-01.xhtml 

section-02.xhtml 

section-03.xhtml

section-04.xhtml

section-05.xhtml 

section-06.xhtml 

Etc....

2
  • Thanks for the suggestions. The only TOC that makes sense for these is one that just links to the start page... there are no "chapters" in the sense of a normal narrative. The links in the page to the other pages are the only navigational aids that make sense, as you don't read the book in a linear order (or even the majority of it, in any single read-through). I've tried in the past to use javascript in epubs, but it is a small subset of that available for webpages and I could never figure it out.
    – John O
    Commented Jul 7, 2023 at 20:54
  • I added another option you might consider for your storyline sub-branches. It's in my detailed comments above, known as "Jump to anchor link".
    – granite
    Commented Jul 22, 2023 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.