{"action":"created","issue":{"url":"https://api.github.com/repos/readium/SDKLauncher-iOS/issues/57","labels_url":"https://api.github.com/repos/readium/SDKLauncher-iOS/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/readium/SDKLauncher-iOS/issues/57/comments","events_url":"https://api.github.com/repos/readium/SDKLauncher-iOS/issues/57/events","html_url":"https://github.com/readium/SDKLauncher-iOS/issues/57","id":77567253,"number":57,"title":"reflow intra spine item page load event triggered too early","user":{"login":"RichardPat","id":4609388,"avatar_url":"https://avatars.githubusercontent.com/u/4609388?v=3","gravatar_id":"","url":"https://api.github.com/users/RichardPat","html_url":"https://github.com/RichardPat","followers_url":"https://api.github.com/users/RichardPat/followers","following_url":"https://api.github.com/users/RichardPat/following{/other_user}","gists_url":"https://api.github.com/users/RichardPat/gists{/gist_id}","starred_url":"https://api.github.com/users/RichardPat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RichardPat/subscriptions","organizations_url":"https://api.github.com/users/RichardPat/orgs","repos_url":"https://api.github.com/users/RichardPat/repos","events_url":"https://api.github.com/users/RichardPat/events{/privacy}","received_events_url":"https://api.github.com/users/RichardPat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-18T08:49:49Z","updated_at":"2015-05-19T15:39:30Z","closed_at":null,"body":"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.\r\n\r\nWhilst 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.\r\n\r\nIn reflowable_view.js :\r\n\r\n    function redraw() {\r\n        var offsetVal =  -_paginationInfo.pageOffset + \"px\";\r\n        \r\n        _$epubHtml.css(\"opacity\", \"0.01\");\r\n        \r\n        if (_htmlBodyIsVerticalWritingMode)\r\n        {   \r\n            _$epubHtml.animate({\r\n                               top: offsetVal,\r\n                               opacity: 1\r\n                               }, 0, function() {\r\n                               });\r\n        }\r\n        else\r\n        {\r\n            var ltr = _htmlBodyIsLTRDirection || _htmlBodyIsLTRWritingMode;\r\n            _$epubHtml.animate({\r\n                               left: ltr ? offsetVal : \"\",\r\n                               right: !ltr ? offsetVal : \"\",\r\n                               opacity: 1\r\n                               }, 0, function() {\r\n                               });\r\n        }\r\n\r\n        showBook(); // as it's no longer hidden by shifting the position\r\n    }"},"comment":{"url":"https://api.github.com/repos/readium/SDKLauncher-iOS/issues/comments/103557264","html_url":"https://github.com/readium/SDKLauncher-iOS/issues/57#issuecomment-103557264","issue_url":"https://api.github.com/repos/readium/SDKLauncher-iOS/issues/57","id":103557264,"user":{"login":"bluefirepatrick","id":241369,"avatar_url":"https://avatars.githubusercontent.com/u/241369?v=3","gravatar_id":"","url":"https://api.github.com/users/bluefirepatrick","html_url":"https://github.com/bluefirepatrick","followers_url":"https://api.github.com/users/bluefirepatrick/followers","following_url":"https://api.github.com/users/bluefirepatrick/following{/other_user}","gists_url":"https://api.github.com/users/bluefirepatrick/gists{/gist_id}","starred_url":"https://api.github.com/users/bluefirepatrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bluefirepatrick/subscriptions","organizations_url":"https://api.github.com/users/bluefirepatrick/orgs","repos_url":"https://api.github.com/users/bluefirepatrick/repos","events_url":"https://api.github.com/users/bluefirepatrick/events{/privacy}","received_events_url":"https://api.github.com/users/bluefirepatrick/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T15:39:30Z","updated_at":"2015-05-19T15:39:30Z","body":"@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.\r\nThanks!\r\nPatrick  "}}