I'm writing a infinity scroll function for my app that will preload pages once the user scrolls up or down. The (Cordova/Phonegap) app will display pages that are dynamically created like this:
<!-- Contents -->
<div id="page-container">
<div id="scroller">
<div id="page_1" class="pagina"></div>
<div id="page_2" class="pagina"></div>
<div id="page_3" class="pagina"></div>
<div id="page_4" class="pagina"></div>
<div id="page_5" class="pagina"></div>
<div id="page_6" class="pagina"></div>
</div>
I want to know which of these page_blabla id's is currently in the viewport so I can determine the next and previous pages to preload. How would one achieve this? The result needs to be a function that returns the id of the page currently in the viewport.
I've seen several examples where people determine if a specific element is in the viewport, but that's not what I need. I want to return the id of the page(div) that is currently in the viewport.
Thx in advance!