readium / ts-toolkit

A toolkit for ebooks, audiobooks and comics written in Typescript
BSD 3-Clause "New" or "Revised" License
59 stars 9 forks source link

positionChanged doesn’t fire reliably for FXL #66

Open JayPanoz opened 2 days ago

JayPanoz commented 2 days ago

It looks like positionChanged event doesn’t necessarily fire for FXL after it did at least once for a spread. It causes a discrepancy between reflow and FXL where your functions are not guaranteed to run for FXL.

Currently Playground is handling the progression and saving the current location through positionChanged but, as you can see on the latest deploy the numbers at the bottom of the page may occasionally get stuck, if you go forward multiple times, and then go backward e.g. you’re back on pages 2–3 of 29 but the progression at the bottom is still showing pages 5–6 of 29.

Correct me if I’m wrong but it’s my understanding FXL doesn’t register a progress message that Navigator can use to fire positionChanged, unlike the Reflow snappers, so first_visible_locator is, unless I’m missing something, the only thing firing positionChanged for FXL.

Navigator’s currentPositionNumbers are correct though, so there are ways around this issue if you need to display them e.g. call on show/hide bottom bar, or navigation actions, except for swipe as it is not implemented yet (#63). In other words, if you want to always display these but find yourself swiping on a mobile, these numbers will not be correct. And it can become quite tricky to keep them in sync as you’ll have to rely on some more complex logic to check when the user has progressed.

chocolatkey commented 1 day ago

@JayPanoz I'll take a look