kotlin-toolkit icon indicating copy to clipboard operation
kotlin-toolkit copied to clipboard

JavaScript preventDefault

Open civodulab opened this issue 3 years ago • 10 comments

Hello, I am working on an interactive book for visually impaired children. I'm looking for an epub reader on android that would allow me to interact without being disturbed by the default actions of the reader. iBooks does it very well (see below). image

Would it be possible to integrate this possibility in your application when using preventDefault ?

Thank you very much for the work you do.

civodulab avatar Apr 28 '22 07:04 civodulab

Absolutely, and this is supposed to work already.

But we don't have much test books for this, so if you are able to share a sample ebook to test it would be super helpful.

mickael-menu avatar Apr 28 '22 07:04 mickael-menu

I am preparing one for you now. I'm working with SVGs, maybe that's why it doesn't work!?

civodulab avatar Apr 28 '22 07:04 civodulab

I'm working with SVGs, maybe that's why it doesn't work!?

I'm not sure, but I can take a look tomorrow. Could you setup a test with an SVG and one without? Thanks!

mickael-menu avatar Apr 28 '22 07:04 mickael-menu

Hello here is a sample epub. I use the ibooks.js script. It works in Thorium.

test_preventDefault.zip

Sorry for my late reply (computer problem).

civodulab avatar May 16 '22 12:05 civodulab

No problem, thanks I will take a look on Friday.

mickael-menu avatar May 16 '22 13:05 mickael-menu

I investigated the issue, the good news is that it's actually working and an easy fix.

The ibooks.js script is using the following to determine if the device is touch based:

iBooks.SUPPORTS_TOUCHES =
  navigator.epubReadingSystem &&
  navigator.epubReadingSystem.hasFeature("touch-events") &&
  iBooks.SYSTEM !== "Windows";

Readium mobile is not implementing the epubReadingSystem object, so it's not recognized as a touch device. I will need to bring this issue up to the dev group before making changes related to this.

It works in Thorium.

Did you test this particular test book? I tried with the latest Thorium version and it didn't work.

Thorium seems to support epubReadingSystem so the issue might be different. I'm using macOS with a touchpad.

mickael-menu avatar May 20 '22 10:05 mickael-menu

Did you test this particular test book? I tried with the latest Thorium version and it didn't work. Yes and I have version 1.8 on PC

civodulab avatar May 20 '22 10:05 civodulab

I'm sorry. It's my script that's wrong. I have to write iBooks.SUPPORTS_TOUCHES = navigator.epubReadingSystem && navigator.epubReadingSystem.hasFeature("touch-events") || iBooks.SYSTEM !== "Windows";

Thanks for opening my eyes. It works in your app

civodulab avatar May 20 '22 11:05 civodulab

That's one way of handling it! But having an epubReadingSystem on mobile might still make sense. I'll keep this issue opened for now. Thanks for reporting.

mickael-menu avatar May 20 '22 11:05 mickael-menu

I'm going to tweak my script to make it work while waiting for an update. Thanks again for the work you do.

civodulab avatar May 20 '22 11:05 civodulab