-
-
Notifications
You must be signed in to change notification settings - Fork 5
Impossible to handle page turn events #10
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
Comments
I also tried using <!-- Draggable DIV -->
<div id="draggable2">
<div id="mydivheader"/>
<button class="button">Go</button>
</div> var observer = new IntersectionObserver(function(entries) {
if(entries[0].isIntersecting === true) {
console.log('Page 2 is visible');
} else {
console.log('Page 2 is not visible');
}
}, { threshold: [1] });
observer.observe(document.querySelector("#draggable2")); ... and ... <div id="draggable4">
<div id="mydivheader"/>
<button class="button">Go</button>
</div>
When opening to page 1, I see in the console:
Turning to page 2, 3:
Turning to page 4,5:
|
Intersection observer wouldn’t be able to keep track of the incoming or outgoing pages on the DOM. That’s useful only when the elements are scrolling and begin to intersect with the viewport when they appear above the fold. In case of a Superbook all the pages and their sub-resources always live (and die) above the fold. So it’s always intersecting per se. What is it that you want to do inside of a page? Does |
No. I placed code like this on pages 2 through 7 of a newly created 8 page book
When initially opening the book all six handlers fire. When stepping forward through the book only the even numbered pages fire, except that the second to last page also fires when turning to the 4th page. When stepping backward through the book only the odd numbered pages fire, except that the second page also fires when turning to the 5th page. What I really need is two custom events available to both exposed pages: PageTurningBegun and PageTurningComplete. The events should carry a detail object like this :
or some other mechanism that ensures script on each page can determine whether or not the event is pertinent, that will be unaffected by deletion or insertion of other pages. |
The instance of Your page-level javascript will execute as soon as a subsequent page frame is attached into the DOM and it reifies successfully. Even when the reader cannot view the newly added pages because they are under the What exact moment are you wanting to have the page-level custom-events fired? When the page under the current one becomes visible to the reader? if yes, then what would define differentiation between a peel-to-peek action vs. actual turn over to the left? What are your thoughts? |
My intention was to start playing a media file through an HTML5 |
Oh you mean autoplaying the video? I am not sure you wanna do that but I'll consider this requirement in the next build of Bookiza / Bubblin. I have used an If such an event was available, how would you have handled firing the video/audio between portrait and landscape modes? The former shows only one page on a mobile whereas the latter will display two pages on the desktop simultaneously. Merry Christmas. |
"how would you have handled firing the video/audio between portrait and landscape modes? " Yeah, that's a complication. Would there be a way to have a global media controller that mediates the state of every page and every media element? |
Yes. Any javascript that you put inside the Layout Templates section of the book will be available on all the pages. How this javascript ties-up events within the context of a page or above at the |
Are there events when pages are added/removed, unambiguously, from the DOM? |
Cue MutationObserver! No, events for the addition and removal of pages from the DOM aren't covered on the existing API of bookiza.js. While this discussion is really helpful in finding this type of requirement, I also feel that writing an observer to watch for DOM level changes on the |
I have place the following JS code on each page, from the cover page through to page 13, with incrementing numbers for each respective page:
If I click on Edit Draft of my book, the Cover page opens and the browser console shows:
When I turn to pgs 2 & 3, the console shows:
to pgs 4 & 5
to pgs 6 & 7
to pgs 8 & 9
to pgs 10 & 11
Question:
How can my JS code know that it's page is open so that it can run and closed so that it should stop?
The text was updated successfully, but these errors were encountered: