draggabilly icon indicating copy to clipboard operation
draggabilly copied to clipboard

Feature: return custom containment

Open karneaud opened this issue 5 years ago • 4 comments

**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 }
....

karneaud avatar Sep 08 '18 16:09 karneaud

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

desandro avatar Sep 11 '18 02:09 desandro

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

devberg avatar Sep 17 '18 16:09 devberg

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...

arthurshlain avatar Jun 19 '19 19:06 arthurshlain

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.

xfra35 avatar Apr 03 '20 15:04 xfra35