-
Notifications
You must be signed in to change notification settings - Fork 45
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
How to detect when page is loaded #53
Comments
Looks like readium fires a pageDidChange event when setting view settings. The code shows that each time you open a page..if the the view type did not change then we set the view settings. I think this is incorrect. We should only be setting view settings if the desired view type changes. In reader_view.js : function openPage(pageRequest, dir) {
initViewForItem(pageRequest.spineItem, function(isViewChanged){
if(!isViewChanged) {
_currentView.setViewSettings(_viewerSettings);
}
_currentView.openPage(pageRequest, dir);
});
} I think you only want to setViewSettings if the desired view type changed..so it should read: function openPage(pageRequest, dir) {
initViewForItem(pageRequest.spineItem, function(isViewChanged){
if(isViewChanged) {
_currentView.setViewSettings(_viewerSettings);
}
_currentView.openPage(pageRequest, dir);
});
} Thoughts? Edit: |
I had to code around this issue. Here is my workaround, which I do not advise as a permanent solution, but may be of assistance. My goal was to register an onclick event on particular elements like audio and video tags. I need to register the event handler any time the DOM is overwritten and I assume it has to be triggered by a PAGINATION_CHANGED ("pageDidChange") event. I was getting the problem where hooking into this event resulted in multiple registrations of my event handlers, so a single click would fire a function multiple times. My solution was to set a flag on the HTML root node itself, knowing that I only need to re-register the event handlers when the HTML node was destroyed. You can see my code here:
If I could rely on PAGINATION_CHANGED to only be triggered when the DOM is overwritten, I could remove the code which checks for a flag. But the solution outlined above seems to be working okay for me for now, so it isn't a blocking issue for me. |
FYI, I filed an issue here about the duplicated event: readium/readium-shared-js#172 @jdempcy note that PAGINATION_CHANGED is triggered every time a reflowable document's page layout is potentially (but strictly-speaking: not necessarily) altered, for example due to changes in font size, line spacing, margins, viewport resizing, etc. |
@danielweck I added My onDocumentLoaded looks like: this.onDocumentLoaded = function() {
window.location.href = "epubobjc:documentLoaded";
}; Am I missing a step somewhere? |
@nodehack to wire the event into a native behaviour, add some handling code here:
|
From Tom Feldman:
Hi all,
I'm wondering if there is an api somewhere in the readium-shared-js or maybe even some standard javascript I can execute to know when javascript is done figuring out its paging routine. I was previously under the impression that a call to ReadiumSDK.reader.openPageNext() would result in a single callback request of pageDidChange when it was finished. If the spine item changes however, this callback is being requested more than once.
Here's a log of the requests:
You'll notice one call to the open next script and two pageDidChange events.
The text was updated successfully, but these errors were encountered: