Webmaster

DHTML : Pages with customised scrollbars
Contents ]
Dr Benton

The Scrolling Principle

A bit of theory before we tackle the scripts.

Imagine a layer measuring 200 x 100 pixels, positioned in the upper left corner of your page (0,0). We want to create a square-shaped window (a clipping area) of 100 x 100 pixels that defines the visible part of our layer. This window is initially placed on the left-hand side of the layer to unveil its left half only.

To scroll our layer within this window, it seems at first sight that a simple offset to the left would do. But this is not the case since a clipping area is bound to its layer and moves with it. So we also need to offset the clipping region by the same amount of pixels with which we move a layer, but in the opposite direction.

So our script foresees two moves relative to the position of our scrollbar's cursor.



  1   2   3   4   5   6   7