Currently if you have a look at the pushlog on the initial PageLoad only 10 entries are shown. I’ve decided that I want the pushlog to initially show 20 entries instead of 10. There are 2 reasons for this, let me explain:
- OnScroll Event doesn’t fire- If the code there are only 10 entries initially, the OnScroll event doesn’t fire since there is no scroll bar present. By making the initial number of entries 20, the scroll bar appears. Now, when the user attempts to scroll down the OnScroll Event is able to fire appropriately (see the below)
- Maintaining Consistency – When the OnScroll event is fired (when the user reaches the end of the page) 20 more entries are loaded each time. To maintain consistency with this pattern the initial number of entries should also be the same number
1 2 3 4 5 | $(window).scroll(function() { if($(window).scrollTop() == $(document).height() - $(window).height()) { renderMorePushLogResults(); } }); |
renderMorePushLogResults(), which loads the new entries is fired when the user reaches the end of the page.
The Code
To make this change I needed to make a couple of back-end changes to the pushlog-feed.py file. Thankfully, there wasn’t need to make any drastic changes. There is a global variable called PUSHES_PER_PAGE, which I set to 20. I also made the following change on line 144 in pushlogSetup()
144 | e = getpushlogentries(conn, (page - 1) * PUSHES_PER_PAGE, 20, tipsonly) |
That’s all the changes I needed to make to implement my change.