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

reflow intra spine item page load event triggered too early #57

Open
RichardPat opened this issue May 18, 2015 · 2 comments
Open

reflow intra spine item page load event triggered too early #57

RichardPat opened this issue May 18, 2015 · 2 comments

Comments

@RichardPat
Copy link

In a reflow document, when attempting to animate the uiwebview during a page transition within the same spine item, I discovered that the page loaded event is sent before the uiwebview visually updates.

Whilst experimenting with animations using javascript, I found a solution that renders the offset change before sending the page load event by animating an opacity change in the document. I'm not certain why it works, or if it's uiwebview specific, but I'm posting it here for further evaluation in the hopes that maybe a cleaner solution can be found.

In reflowable_view.js :

function redraw() {
    var offsetVal =  -_paginationInfo.pageOffset + "px";

    _$epubHtml.css("opacity", "0.01");

    if (_htmlBodyIsVerticalWritingMode)
    {   
        _$epubHtml.animate({
                           top: offsetVal,
                           opacity: 1
                           }, 0, function() {
                           });
    }
    else
    {
        var ltr = _htmlBodyIsLTRDirection || _htmlBodyIsLTRWritingMode;
        _$epubHtml.animate({
                           left: ltr ? offsetVal : "",
                           right: !ltr ? offsetVal : "",
                           opacity: 1
                           }, 0, function() {
                           });
    }

    showBook(); // as it's no longer hidden by shifting the position
}
@bluefirepatrick
Copy link
Member

@RichardPat thank you for sharing this code. We tried this approach in our WKWebView based Readium reader and found that it did not reliably send the event after the page rendered. (The timing of these things seems so platform, device and book dependent). Unfortunately it seems like there is no reliable event from UIWebView or WKWebView that is sent after a successful render pass (which is a common gripe out there on the Internet) but it is certainly worth exploring more. If you find something interesting please share it.
Thanks!
Patrick

@danielweck
Copy link
Member

Possibly duplicate of: #53
See also: readium/readium-shared-js#172
@jccr has been working on this: readium/readium-shared-js#179

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

No branches or pull requests

4 participants