15

50 個の div がありますが、ウィンドウには 25 個しか表示されません。これらの div でドラッグ アンド ドロップ アクティビティを実行します。最初の div を 25 番目の div の近くにドラッグすると、自動的にスクロールして残りの div が表示されます。これを行う方法jqueryで?何か案が?

Draggable() ではなくNestableを使用しています

4

4 に答える 4

2

ウィンドウの下部を知りたい場合は、確認できます

$(window).height()

そして$(window).scrollTop();

于 2013-07-27T12:06:16.133 に答える
1

これは古いトピックであることは承知していますが、この機能は待機中なので、apaul34208 のコードを改善したところです。

$(window).mousemove(function (e) {
    if ($('.dd-dragel') && $('.dd-dragel').length > 0 && !$('html, body').is(':animated')) {
        var bottom = $(window).height() - 50,
            top = 50;

        if (e.clientY > bottom && ($(window).scrollTop() + $(window).height() < $(document).height() - 100)) {
            $('html, body').animate({
                scrollTop: $(window).scrollTop() + 300
            }, 600);
        }
        else if (e.clientY < top && $(window).scrollTop() > 0) {
            $('html, body').animate({
                scrollTop: $(window).scrollTop() - 300
            }, 600);
        } else {
            $('html, body').finish();
        }
    }
});
于 2015-06-08T14:33:54.883 に答える