Is there an easy way to do click-and-drag scrolling in text frames?
Question by Skilldrick
I have a div with overflow:auto
and a scroll bar, and I’d like to be able to drag the contents to scroll. I don’t need to be able to select text. Is there an easy way to do this? A jQuery plugin would be good, otherwise plain old JavaScript would be fine.
It seems I haven’t made myself clear enough. There’s a div with a fixed height that I want to scroll. Instead of picking up the scroll bar, I want to click and drag inside the text in the opposite direction. Like on an iPhone. Like in Photoshop when you hold down space and drag.
-------------------
| | |
| | |
| |||
| | |
| <----------- click here and drag to scroll.
| | |
| | |
-------------------
Answer by John Hartsock
Here is a nice implemenation of drag and scroll divs
Answer by Starx
There is plugin in Jquery UI called draggable
through this you can change any element into draggable object
Here is the link for the demo
http://jqueryui.com/demos/draggable/
It is as simple as this
<script type="text/javascript">
$(function() {
$("#draggable").draggable();
});
</script>
It is also possible to make it scrollable inside a div. Check the demo page