desandro / draggabilly

:point_down: Make that shiz draggable

Home Page:https://draggabilly.desandro.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: return custom containment

karneaud opened this issue · 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 }
....

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

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

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

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.