Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

draggable / moveable <div> horizontally

How can I make a div that is draggable / moveable horizontally, but not vertically? I would prefer if this could be done without JQuery UI. JQuery is fine. Or vanilla JS.

like image 862
IMUXIxD Avatar asked Apr 04 '13 03:04

IMUXIxD


1 Answers

Creating such a behavior yourself would be quite a bit of work. I would recommend using jquery ui :

http://jsfiddle.net/basarat/f7nNf/1/

Its a single line of code:

$( "#draggable" ).draggable({ axis: "x" });

And you don't event need to download the complete jquery ui. You can do a custom build with only draggable here : http://jqueryui.com/download/

Read more about draggable here: http://jqueryui.com/draggable/#constrain-movement

like image 176
basarat Avatar answered Sep 28 '22 14:09

basarat