Enzio
Enzio

Reputation: 387

jQuery UI Draggable Limitations Containment

I have two divs, the parent is smaller then it's child. I want to have the child's drag limit to the border of the container. However, this does not seem to work with the usual containment object. How could I do this properly?

Example: http://jsfiddle.net/Lr0s3tj7/

<div class='wrap'> <!-- smaller then child -->
    <div class='inner'> <!-- larger then parent -->

    </div>
</div>

Upvotes: 0

Views: 155

Answers (1)

Eric So
Eric So

Reputation: 465

use array to define the border should do the trick

 $(".inner").draggable({ 
    axis: 'x', 
    containment: [-100, 0, 0, 200 ],
    revert: true
});

http://jsfiddle.net/js09nbj1/

edited the answer to meet the requirement

Upvotes: 1

Related Questions