Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/viewport clipped #188

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from

Conversation

johanpoirier
Copy link

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 and others added 22 commits September 3, 2014 15:56
CSS prefixes, including special treatment for transitions on transforms
… or scroll views. Fixes readium/readium-js-viewer#232

(fixes Chrome extension/cloud reader, as well as native apps (although they do not expose "zoom" UI affordances yet))
(trivial tested fix, no need for feature branch + pull request)
Added info about where to find information about the licensing.
Conflicts:
	README.md
@johanpoirier
Copy link
Author

Only the "Files changed" section is relevant here.

@danielweck
Copy link
Member

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).

@johanpoirier
Copy link
Author

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.

@danielweck
Copy link
Member

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");

@johanpoirier
Copy link
Author

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.

@danielweck
Copy link
Member

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

@johanpoirier
Copy link
Author

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

@danielweck, will this PR be merged?

@johanpoirier
Copy link
Author

What is the status on this PR?

@danielweck
Copy link
Member

@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).


_paginationInfo.pageOffset = (_paginationInfo.columnWidth + _paginationInfo.columnGap) * _paginationInfo.visibleColumnCount * _paginationInfo.currentSpreadIndex;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I like the idea of deferring the numerical rounding until the last minute (i.e. application of CSS rules), I am concerned that / curious about the fact that _paginationInfo.pageOffset potentially contains many decimal places, and is used in the "CFI navigation logic" calculations:
https://github.com/readium/readium-shared-js/blob/develop/js/views/cfi_navigation_logic.js#L116

    function getVisibleContentOffsets() {
        if(isVerticalWritingMode()){
            return {
                top: (options.paginationInfo ? options.paginationInfo.pageOffset : 0)
            };
        }
        return {
            left: (options.paginationInfo ? options.paginationInfo.pageOffset : 0)
                * (isPageProgressionRightToLeft() ? -1 : 1)
        };
    }

@danielweck
Copy link
Member

Competing solution? #288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants