desandro / draggabilly

:point_down: Make that shiz draggable
https://draggabilly.desandro.com
MIT License
3.86k stars 386 forks source link

Feature: return custom containment #197

Open karneaud opened 6 years ago

karneaud commented 6 years ago

**feature request

Is there a way to return a rect object if not a function instead of an element in order to set the movement contraint?

e.g

new Draggabilly(elem, { 
  containment: { x: 20, y: 200, width: 400, height: 400 }
....
desandro commented 6 years ago

Add a 👍 reaction to this issue if you would like to see this feature added. Do not add +1 comments — They will be deleted.

devberg commented 6 years ago

this should be a very-very usefull feature!!.. 👌

arthurshlain commented 5 years ago

Possible to make div inside parent div draggable in one way? For example, swipe push to the left/right side, hide notification at bottom of page by swipe down gesture...

xfra35 commented 4 years ago

This would be a very convenient feature.

Until it gets implemented, we can get a similar effect by passing an absolutely positioned element to the containment option:

var $containment=$('<div id="containment"></div>').css({
    position: 'absolute',
    left: '20px',
    top: '200px',
    width: '400px',
    height: '400px'
}).insertBefore($draggable);

$draggable.draggabilly({
    containment: $containment[0]
});

See a demo here.