0

I have a huge list of items that can be sorted by dragging them. I noticed that once the list gets very long and overflows its parent container's height, dragging an item to a position not currently visible gets very inconvenient.

Here is an example (jsFiddle).

I want to drag the first element to right before the last element in one gesture. Currently that's not possible because I can't drag and scroll at the same time. Is there a setting that enables auto-scrolling the container as soon as I drag one of its children near the border of the container?

I have tried different settings for appendTo as well as containment, but no setting had the desired effect.

Updated with solution

Thanks to the answer by @Shannon below, I was able to get it working, you can find the updated solution here.

4

1 回答 1

1

一旦用户拖过滚动的一半,您就必须创建一个滚动事件。这很简单。

$(li).drag(function(e) {
    $("ul").scrollTop(function(i, v) {
        var h = $(ul).height();
        var y = e.clientY - h / 2;
        return v + y * 0.1;
    });
});

这行不通,但这是一个开始,因此您可以了解如何处理它,我今天早上没有时间完全完成它!

于 2012-08-19T21:58:38.837 回答