Skip to content

Various reflowable EPUB columns shift issues #166

Closed
readium/r2-navigator-kotlin
#178
@mickael-menu

Description

@mickael-menu
Member

On some books, when swiping through the content, the EPUB columns are shifting and are not aligned anymore. This reverts by tapping on the edges.

I could reproduce this on oryel_1984.zip from this issue: #167

Screenshot_20200629-101320

Activity

mickael-menu

mickael-menu commented on Aug 18, 2020

@mickael-menu
MemberAuthor

Another related issue, the columns are slightly shifting in long resources, such that the last page is not centered. For example with Gatsby:

Screenshot_20200818-111928

changed the title [-]EPUB columns shift when swiping through a resource[/-] [+]Various reflowable EPUB columns shift issues[/+] on Aug 19, 2020
mickael-menu

mickael-menu commented on Aug 19, 2020

@mickael-menu
MemberAuthor

Another issue, I can move the offset of a page by pinching it, then panning it in a single gesture.
Screenshot_20200819-162838

johanpoirier

johanpoirier commented on Sep 3, 2020

@johanpoirier
Contributor

I also have issues with going to a locator with an anchor fragment (i.e. Chapitre02.html#int02-s3).
The columns are shifted as well. Loading the webView with an URL containing an anchor is problematic. Is it CSS related?

nidhinprathap

nidhinprathap commented on Sep 5, 2020

@nidhinprathap

@johanpoirier there's a method that's javascript getting called but the definition is missing. Please check the below-mentioned ticket.
readium/r2-testapp-kotlin#351

For now, you can change tat and call scrollToTag method in utility.js

johanpoirier

johanpoirier commented on Sep 7, 2020

@johanpoirier
Contributor

For now, you can change tat and call scrollToTag method in utility.js

Yes I did see that and I used scrollToId method instead. But the behaviour is sometimes odd. When the URL has an anchor, the page displayed is the one before so I'm trying to debug the issue right now.

nidhinprathap

nidhinprathap commented on Sep 7, 2020

@nidhinprathap

ah for that can u try this

var scrollAnchor = function(id) {
        var element = document.getElementById(id);
        var elementOffset = element.scrollLeft // element.getBoundingClientRect().left works for Gutenbergs books
        if (elementOffset == 0) {
            elementOffset = element.getBoundingClientRect().left;
        }
        var offset = Math.round(window.scrollX + elementOffset);

        document.scrollingElement.scrollLeft = snapOffset(offset);
 
};

@johanpoirier can you try this. Add this method to utils.js. And call scrollAnchor from Kotlin like this

val id = url.substring(url.indexOf('#')+1); // this is to ignore hash from start
webView.loadUrl("javascript: scrollAnchor('$id');")
johanpoirier

johanpoirier commented on Oct 27, 2020

@johanpoirier
Contributor

Another issue, I can move the offset of a page by pinching it, then panning it in a single gesture.

This is caused by those lines of code: https://github.com/readium/r2-navigator-kotlin/blob/develop/r2-navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt#L735-L738

The mLastMotionX is set by the second finger down, so the xDiff is almost never greater than mTouchSlop: https://github.com/readium/r2-navigator-kotlin/blob/develop/r2-navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt#L677

My question is: why are we mixing touch pointers values into mLastMotionX?

mickael-menu

mickael-menu commented on Nov 9, 2020

@mickael-menu
MemberAuthor

It looks like the offset issues are caused by some rendering bug in Android's Web View, but we have a potential workaround enabled by Readium CSS: readium/css#97

mickael-menu

mickael-menu commented on Nov 12, 2020

@mickael-menu
MemberAuthor

I pushed a PR which addresses the offset issue at least in my use cases, using the latest version of Readium CSS. I'm not 100% sure it fixes all of the reported offset issues.

readium/r2-navigator-kotlin#178

Note that utils.js is completely rewritten, to align with the Swift version. I didn't see any regression with RTL (which didn't work anyway in my tests) but something to keep in mind in case some other issues pop up.

@johanpoirier

I also have issues with going to a locator with an anchor fragment (i.e. Chapitre02.html#int02-s3).
The columns are shifted as well.

This should be fixed as well, would you mind double-checking with this PR?

johanpoirier

johanpoirier commented on Nov 13, 2020

@johanpoirier
Contributor

thanks @mickael-menu , I'll test that next monday.

johanpoirier

johanpoirier commented on Nov 16, 2020

@johanpoirier
Contributor

This should be fixed as well, would you mind double-checking with this PR?

I just tested it on my own app and the r2-testapp but the offset issue is still present in this case.
I fixed it on my app a few weeks ago, I'll try to put the fix in a PR tomorrow.

mickael-menu

mickael-menu commented on Nov 16, 2020

@mickael-menu
MemberAuthor

I fixed it on my app a few weeks ago, I'll try to put the fix in a PR tomorrow.

Sounds good, might be that we're using different test cases. Thanks for taking a look!

added theissue type on Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @johanpoirier@nidhinprathap@mickael-menu

      Issue actions

        Various reflowable EPUB columns shift issues · Issue #166 · readium/kotlin-toolkit