Lets say there is a draggable object capable of being dragged only on one axis.
Is there a way to programmatically move it? Either to start, or by a delta. Of course I could go and change its css left
property, but that wouldn't trigger the dragging events jQuery offers.
I was expecting to find a dragBy(x,y)
method to the draggable.
Here is the example: http://jsfiddle.net/odyodyodys/daHU8/
html:
<div id="theButton">Reset position</div>
<div id="theDiv">Lorem ipsum dolor sit amet</div>
Js:
$("#theDiv").draggable({
axis: "x",
cursor: "pointer"
});
Css:
#theDiv {
display:block;
width: 100px;
height: 100px;
overflow: hidden;
margin-top: 80px;
background-color: green;
}
#theButton {
border: 1px solid;
width:80px;
cursor: pointer;
}
Is there a way to move the draggable element (the theDiv
here) by a delta or to the initial position, after moving it across the x axis?