[Javascript] scrolling function

jeffrey morin rufus2021 at gmail.com
Tue May 4 12:10:16 CDT 2010


On Mon, May 3, 2010 at 11:12 PM, Paul Novitski <paul at juniperwebcraft.com>wrote:

> At 4/2/2010 07:31 AM, jeffrey morin wrote:
>
>> I am building a javascript scroller that has two buttons. When one is
>> clicked it slides a list up and the other slides it down. It works fine
>> except that I can't seem to wrap my head around how to get it to stop once
>> it reaches the end of my list. Right now it slides by a set number of
>> pixels
>> but I would like to avoid the white space at the bottom. We're trying to
>> emulate the functionality on this site.
>>
>> http://www.thefrisky.com/
>>
>> If you scroll down it's in the right column marked "most viewed". They
>> have
>> the two arrows for sliding up and down. When you get to the end of the
>> list
>> it stops. Mine just slides by a set number of pixels like I said so it
>> keeps
>> going and gives me white space. Using jQuery but am trying to avoid an
>> entire plugin because I don't need all of the other options that those
>> plugins come with.
>>
>
>
> Since you haven't shared your script, there's no way anyone can help you
> debug it. The problem is clearly to limit scrolling to the height of the
> scrolled object within the height of its container. If the current scroll
> position + new scroll height > content height, set new scroll height =
> content height - current scroll position.
>
> Stepping back, however, I'd like to question the whole effort.
>
> Why use JavaScript for this at all? Place the list inside a div styled with
> {overflow: scroll} and move on.
>
> Why replace normal functioning of the browser (a div with a scrollbar) with
> a custom control that doesn't work as well as the original? Will your
> JavaScript widget work with page-up & page-down keys and the mouse
> scrollwheel?
>
> The example on the thefrisky page you point to is, quite unnecessarily,
> devoid of content and functionality when JavaScript isn't running. It is
> therefore invisible to search engines, mobile devices, and other user agents
> that aren't processing script. Is that desireable? Much better to engineer
> the widget to display and function without scripting, then enhance it with
> JavaScript as you want.
>
> Curiously,
>
> Paul
> __________________________
>
> Paul Novitski
> Juniper Webcraft Ltd.
> http://juniperwebcraft.com
> _______________________________________________
> Javascript mailing list
> Javascript at lists.evolt.org
> http://lists.evolt.org/mailman/listinfo/javascript


Thank you for your response Paul. I ended up figuring out a way to do it. I
agree on not using JavaScript for something like this when all you need is
the browser scrollbars. But unfortunately, like in too many cases, I (the
developer) was not allowed to make the development decisions. For some
reason, people still think that mimicking other websites' looks and
functionality is better than taking the time to design a proper look and
accessible functionality. Go figure.

Jeff


More information about the Javascript mailing list