readium-shared-js icon indicating copy to clipboard operation
readium-shared-js copied to clipboard

Fix/viewport clipped

Open johanpoirier opened this issue 9 years ago • 10 comments

Fixes #181 :

Reflowable document viewport gets clipped when enlarged (CSS columns) because the page offset is computed with rounded values.

To fix that, we do not round the column width value, but we round the page offset value instead. The page offset value is used to display the current content.

johanpoirier avatar Jun 10 '15 08:06 johanpoirier

Only the "Files changed" section is relevant here.

johanpoirier avatar Jun 10 '15 08:06 johanpoirier

I had a look at possible regression bugs by hunting down usages of columnWidth (now a number with floating point precision / many decimal places), and as long as CSS is happy with long numbers in px values ; in all web browsers ; then this code change should be alright. Overall, this looks like a relatively safe PR. Note that as I have not been able to reproduce the original problem (inaccurate page offset), I have not actually tested this proposed fix. It does make a lot of sense though. PS: as Johan said, only the "Files changed" section is relevant, let's not merge the actual commit diff (instead: let's just cherry-pick the code diff).

danielweck avatar Jun 10 '15 12:06 danielweck

I don't think that columnWidth is directly used in CSS, but the pageOffset value is. That's why I added the Math.round in the onPaginationChanged function.

johanpoirier avatar Jun 10 '15 13:06 johanpoirier

I was thinking of: https://github.com/readium/readium-shared-js/blob/develop/js/views/reflowable_view.js#L630

_$epubHtml.css("width", (_htmlBodyIsVerticalWritingMode ? _lastViewPortSize.width : _paginationInfo.columnWidth) + "px");
_$epubHtml.css("column-width", _paginationInfo.columnWidth + "px");

danielweck avatar Jun 10 '15 13:06 danielweck

We can add Math.round for those lines or just let browsers deal with decimal pixels.

I just tested my solution on popular browsers and it works fine (Chrome, Firefox, Safari, IE10 & IE11). I should test it on Android and iOS as well to be sure.

johanpoirier avatar Jun 10 '15 14:06 johanpoirier

That's great @johanpoirier thank you very much for your time on this! :)

danielweck avatar Jun 10 '15 15:06 danielweck

I ran some tests on Android and iOS and it works fine.

@danielweck, will this PR be merged?

johanpoirier avatar Jun 17 '15 13:06 johanpoirier

What is the status on this PR?

johanpoirier avatar Jun 25 '15 06:06 johanpoirier

@johanpoirier we're waiting to hear more about another CSS column-pagination bug (missing reflowable page), so we can see the "big picture". This PR just needs to be updated with git merge develop in the TEA-ebook:fix/viewport-clipped branch (recent AMD-RequireJS refactoring).

danielweck avatar Jul 12 '15 21:07 danielweck

Competing solution? #288

danielweck avatar Jul 22 '16 17:07 danielweck