a5hik / ng-sortable

AngularJS Library for Drag and Drop, supports Sortable and Draggable. Supports Touch devices.
http://a5hik.github.io/ng-sortable/
MIT License
1.15k stars 314 forks source link

Dragelement's position is incorrect #174

Open Liujianfu opened 9 years ago

Liujianfu commented 9 years ago

Sometimes the container's height is 0 if I use Body as the containment, so the dragelement's position is incorrect. I cannot find the root cause.

Jeevanandanj commented 9 years ago

Me to posted the same kind of issue https://github.com/a5hik/ng-sortable/issues/202

michael9580 commented 9 years ago

I had a similar issue and I'm not sure if this is 100% related but i changed the .as-sortable-drag class in ng-sortable.style.css to

.as-sortable-drag {
position: fixed;
opacity: .8; 
}

Now the draggable element sticks to the cursor.

Jeevanandanj commented 9 years ago

Sorry Michael. This solution is not working.

By default if the draggable elements are only in the view port then dragging is working perfectly.

Root cause: If we have the draggable elements overflowing the viewport, then this is not working as expected.

SakshiParakh commented 8 years ago

Are you using Bootstrap? I had faced a similar issue with the positioning of the item. this was my code snippet:

 $scope.sortableOptions = {
    containment: "#sort_" +index+ "",
    scrollableContainer: "#sort_" +index+ "",
    containerPositioning: 'relative',
    accept: function (sourceItemHandleScope, destSortableScope) {
      return sourceItemHandleScope.itemScope.sortableScope.$id === destSortableScope.$id;
    }
 };

As mentioned in the documentation, after using containerPositioning option and setting it to relative , the issue got resolved.

If still you're facing a problem, could you send a code snippet and elaborate a little more.

chenbin92 commented 8 years ago

@SakshiParakh Set containerPositioning: 'relative', this is perfect.

margru commented 8 years ago

Hi, any piece of advice for this issue when using Angular Material grid layout? containment + containerPositioning didn't help here...

Thanks.

ricktoews commented 8 years ago

I'm finding that containment + containerPositioning does give the dragging element a top position that's a consistent distance from the original element, regardless of how far down the page the element is. However, the dragging element is not positioned correctly with respect to the original (several pixels to the left, perhaps 50-70 too high). Is there a configuration option to deal with this?

simvol commented 6 years ago

I had this problem while using Bootstrap 3, what caused it was lack of "row" elements.

codejunkie1609 commented 3 years ago

Hey can you elaborate what you mean by lack of "row" elements? I'm facing the issue as well. @simvol