{"action":"created","issue":{"url":"https://api.github.com/repos/futurepress/epub.js/issues/274","labels_url":"https://api.github.com/repos/futurepress/epub.js/issues/274/labels{/name}","comments_url":"https://api.github.com/repos/futurepress/epub.js/issues/274/comments","events_url":"https://api.github.com/repos/futurepress/epub.js/issues/274/events","html_url":"https://github.com/futurepress/epub.js/issues/274","id":105544282,"number":274,"title":"Pagination error:Total pages have different result in first load and pagination","user":{"login":"yinhaibo","id":8294580,"avatar_url":"https://avatars.githubusercontent.com/u/8294580?v=3","gravatar_id":"","url":"https://api.github.com/users/yinhaibo","html_url":"https://github.com/yinhaibo","followers_url":"https://api.github.com/users/yinhaibo/followers","following_url":"https://api.github.com/users/yinhaibo/following{/other_user}","gists_url":"https://api.github.com/users/yinhaibo/gists{/gist_id}","starred_url":"https://api.github.com/users/yinhaibo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yinhaibo/subscriptions","organizations_url":"https://api.github.com/users/yinhaibo/orgs","repos_url":"https://api.github.com/users/yinhaibo/repos","events_url":"https://api.github.com/users/yinhaibo/events{/privacy}","received_events_url":"https://api.github.com/users/yinhaibo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-09T08:32:35Z","updated_at":"2015-09-10T06:29:07Z","closed_at":null,"body":"I create a EPUB directory, which have only a chapter and with some text, images and videos.\r\nIn simulator iPhone 6, the chapter first load have only 3 pages, and after pagination, total pages is 4 pages.\r\nI track renderer.js mapPage function. I found some strange problem:\r\n1. the renderer of current display chapter and the hidden renderer of pagination have different render result(different page count).\r\n2. the mapPage does not check non text node in html. there be **lack one page** while the chapter end with a non-text element, and just the first node on new page, such as a image.\r\n\r\nI checkout renderer's style, I got same result:\r\n[First load on startup]\r\n[Log] -webkit-transform: translate(0px, 0); overflow: hidden; width: auto; height: 569.421875px; -webkit-column-axis: horizontal; -webkit-column-fill: auto; -webkit-column-width: 376px; -webkit-column-gap: 80px; (console-via-logger.js, line 173)\r\n[Pagination]\r\n[Log] -webkit-transform: translate(0px, 0); overflow: hidden; width: auto; height: 569.421875px; -webkit-column-axis: horizontal; -webkit-column-fill: auto; -webkit-column-width: 375px; -webkit-column-gap: 80px; (console-via-logger.js, line 173)\r\n\r\n(https://github.com/futurepress/epub.js/blob/master/src/renderer.js#L601)\r\nthis.layout.colWidth= 375(for first load), **1740** (for pagination)\r\nthis.layout.spreadWidth=455, 1820\r\nrenderer.doc.documentElement.clientHeight = 569, **0**(for pagination)\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/futurepress/epub.js/issues/comments/139129745","html_url":"https://github.com/futurepress/epub.js/issues/274#issuecomment-139129745","issue_url":"https://api.github.com/repos/futurepress/epub.js/issues/274","id":139129745,"user":{"login":"yinhaibo","id":8294580,"avatar_url":"https://avatars.githubusercontent.com/u/8294580?v=3","gravatar_id":"","url":"https://api.github.com/users/yinhaibo","html_url":"https://github.com/yinhaibo","followers_url":"https://api.github.com/users/yinhaibo/followers","following_url":"https://api.github.com/users/yinhaibo/following{/other_user}","gists_url":"https://api.github.com/users/yinhaibo/gists{/gist_id}","starred_url":"https://api.github.com/users/yinhaibo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yinhaibo/subscriptions","organizations_url":"https://api.github.com/users/yinhaibo/orgs","repos_url":"https://api.github.com/users/yinhaibo/repos","events_url":"https://api.github.com/users/yinhaibo/events{/privacy}","received_events_url":"https://api.github.com/users/yinhaibo/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T06:29:07Z","updated_at":"2015-09-10T06:29:07Z","body":"It took me 4 days to find out, today, I notice there is a small difference in my Log:\r\n**-webkit-column-width:376px**\r\n**-webkit-column-width:375px**\r\nThere is 1 pixel between them? Why!!!\r\nI changed following code in:\r\n(https://github.com/futurepress/epub.js/blob/master/src/render_iframe.js#L128)\r\n```\r\n-       this.width = this.iframe.getBoundingClientRect().width || width;\r\n-       this.height = this.iframe.getBoundingClientRect().height || height;\r\n+       this.width = width || this.iframe.getBoundingClientRect().width;\r\n+       this.height = height || this.iframe.getBoundingClientRect().height;\r\n```\r\n(https://github.com/futurepress/epub.js/blob/master/src/book.js#L348)\r\n```\r\n-       renderer.initialize(hiddenEl);\r\n+       renderer.initialize(hiddenEl, width, height);\r\n```\r\n\r\nthen, it seems ok in pagination.\r\nONLY ONE PIXEL MAKE BIG DIFFERENCE??\r\n\r\nThe second problem, I try to add a checkNonText function to calc page position in \r\n(https://github.com/futurepress/epub.js/blob/master/src/renderer.js#L601)\r\nanother question is:\r\n** Why need to re-get XPath from document in PUBJS.Chapter.prototype.cfiFromRange function?**\r\nThe node is from DOM tree, I think that it is a normal node or range, why need to research from DOM tree in this function?\r\n(https://github.com/futurepress/epub.js/blob/master/src/chapter.js#L148)"}}