views:

417

answers:

1

I have a layout as follows:

<div style="width: 300">
    <div style="width: 300">Some Content</div>
</div

I want to be able to mousedown in the content DIV and be able to move it left to right, or scroll it in other words :)

What would be the best way of being this?

I would prefer it in JavaScript mainly :)

A: 

Easiest would be to use Mootools or jQuery. Both have "drag" interfaces to handle this sort of thing, and handle all the cross-browser compatibility problems.

If you're fixed on rolling your own, then the basic process is to attach mousedown/mouseup events on the parent div to initiate the dragging stuff, slap a handler on mousemove to capture the motion events, and adjust the parent div's scroll offsets as appropriate.

Marc B