v0.7 Release – The Scroll Bar Problem

As a part of one of my goals for this release I want to find a solution to the pesky scroll bar problem. Let me explain:

The Problem

Basically, by default the pushlog only loads 10 entries, which doesn’t fill out the entire page and thus the scroll bar does not show up. Now, this means that when the user tries to scroll down (to load more entries) nothing happens as the scroll bar event doesn’t fire. You might be wondering why not just load more entries by default? Well, first of all that isn’t an elegant solution, it’s a cop out and second, different users have varying screen sizes and thus this solution is not feasible.

A dynamic solution is needed where, according to the users screen size, a varying amount of entries are loaded automatically to fill out the page so that the scroll bar appears.

Possible Solutions

This problem is quite frustrating, to be honest. I’ve tried various methods to solve this issue but none have worked ideally. So far, I’ve tried to approach this problem from one angle, using the onload attribute of the body tag through which you can pass in a function that is executed when the page loads. In this function, I call my OnScroll function that loads more entries according to the screen size. So basically a loop is required but this reveals a very frustrating issue. Any kind of loop in this function causes the browser to throw an unresponsive script error. Since, I absolutely have to have a loop to implement the desired functionality, this solution is useless.

Next, I tried to get rid of the unresponsive script error by using setTimeout() which delays the execution of a function by x milliseconds. This gets rid of the script error that the browser was throwing but the browser Gods were still unhappy, as Firefox decided to freeze on me for 10-15secs. Once these seconds passed by the browser unfroze but my solution still didn’t work (no entries were loaded). Basically, nothing happened!

So all in all my attempts to come up with an efficient solution have all been futile, so far.

New Idea

I had a talk with Dave Humphrey this week about this scroll bar problem. He came up with an interesting idea. He approached the problem from a different angle. What if you could get the browser to tell you whether the scroll bar is available or not. So all you would do is keep on adding new entries until the scroll bar appeared and then stop.

I hadn’t thought about the problem in the manner that Dave highlighted. I think he might be onto something here. I’ll have to look into how I can do this in JavaScript. I am certain that there is a way to know whether the scroll bar is present or not. This new lead sounds very promising!

Stay tuned! I’ll be blogging about my findings very soon!

This entry was posted in DPS911, Mercurial Project, Open Source and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>