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

Rendering problems in IOS 8 #204

Closed
ghost opened this issue Mar 25, 2015 · 8 comments
Closed

Rendering problems in IOS 8 #204

ghost opened this issue Mar 25, 2015 · 8 comments

Comments

@ghost
Copy link

ghost commented Mar 25, 2015

Hello!

I'm having some troubles using epub.js embedded inside a webview at IOS 8. I've already found this issue #162 but I don't know if it's exactly the same bug.

The problem is that, when I go to the next page, the text inside the iframe begins to "move", the resize event is triggered infinitely on window, and inline styles on iframe are continuously changing.

I tried to override the setLeft method using:

EPUBJS.Render.Iframe.prototype.setLeft = function(leftPos){
    this.docEl.style["-webkit-transform"] = 'translate('+ (-leftPos) + 'px, 0)';
};

but It doesn't work. The only solution that seems to work properly is defining an explicit width and height at epub declaration:

book = ePub("/path/to/book/, { width: 320, height: 400 });

Is there any other solution to this problem? I would prefer a fluid iframe instead of one width fixed sizes.

Thanks in advance!

@Anzumana
Copy link

Anzumana commented Apr 9, 2015

Don't think there is a fix for this apart from the one you already mentioned. sorry

@crododile
Copy link

i dealt with a the same thing of safari constantly triggering the resize event. Solved problem by dynamically grabbing the values for width and height.
In initialization you could do something like

var width = $('#read-area').width()
book = ePub("/path/to/book/, { width: width, height: 400 });

also I overwrote the renderer.prototype.onResized on my renderer instance with something like

width = $('#read-area').width()
height = $('#read-area').height()
this.resize(width, height, true);

This appears to be almost exactly what the prototype method does, but it wasn't working. I also had to manually bind the browser resize event to trigger the function.

@donflopez
Copy link

We have a solution.

We overwrote this methods:

// iframe.js
EPUBJS.Render.Iframe.prototype.resized = function(e){
        // Get the fractional height and width of the iframe
      this.width = parseInt(window.getComputedStyle(document.getElementById('book-reader')).width);
      this.height = parseInt(window.getComputedStyle(document.getElementById('book-reader')).height);
    };


// renderer.js
 EPUBJS.Renderer.prototype.onResized = function(e) {
      var width = parseInt(window.getComputedStyle(document.getElementById('book-reader')).width),
          height = parseInt(window.getComputedStyle(document.getElementById('book-reader')).height);

        this.resize(width, height, false);
    };

@bahinapster
Copy link

@donflopez doesn't work for me

@fchasen
Copy link
Contributor

fchasen commented Sep 29, 2015

Thanks all for this discussion - the auto expanding iframe in IOS are still an issue that break the rendering on IOS if you don't see the width and height.

Since we already check for mobile browsers, I think we should use that to automatically set a width and height in it isn't already set as @donflopez and @crododile showed above.

@fchasen fchasen added the Todos label Sep 29, 2015
@zmanring-zz
Copy link

@fchasen Any progress on this Fred? I am implementing an iPad solution now and need some kind of work around for iOS.. thanks!

@jbhorsewriter7
Copy link

jbhorsewriter7 commented Nov 18, 2016

@fchasen I need this too... is there any way that we could help?

I am using the following method (hopefully this fix is still relevant):

var reader = ePubReader(FILENAME);

@Raymond26
Copy link

Setting an explicit width and height for the ePub worked for me. Although there would be this issue where the ebook would keep shifting to the right every time by a pixel or two I went to the next page, and it would reset back to normal at the start of a chapter. I fixed this by making sure that the width was always even.

if (width % 2) width = width + 1;

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

9 participants