epeleg
epeleg

Reputation: 10945

how to implement scroll by drag using jquery

Given a div with preset height (say 200px) set to hide overflowing content, and a child div with height of 600px, I want to be able to scroll the content div using a drag action.

so that when a mouse down starts at some point and moves several pixels the content will scroll as well.

optimally I would like to have some "speed and friction" logic added to this behavior so that you could "toss" the content div and have if continue its movement past the drop point.

Does anyone know of such ready made functionality? in either JQuery / JQuery Ui or some plugin ? if not the implementation idea would also be welcome.

Upvotes: 0

Views: 8829

Answers (2)

epeleg
epeleg

Reputation: 10945

I ended up using the following jquery plugin: http://the-taylors.org/jquery.kinetic/

It is simple and there are things to desire about it, but it is very small and has the basic functionality I was looking for.

Upvotes: 2

Ry-
Ry-

Reputation: 225164

I like iScroll 4, though it has some problems with fixed positioning if that's an issue.

Here's a live demo.

Upvotes: 1

Related Questions