JQuery UI draggable position affects scrollTop? (JSFiddle enabled)

http://jsfiddle.net/mgJf2/2/

After enabling jQueryUI, the only javascript is:

$("#scrollbox").draggable({
    axis: 'y',
    drag: function(event, ui) {
         $(document).scrollTop(ui.position.top);
    },
});

Scrolling a document has a compact effect on a div-div div (which I thought had a fixed position). This makes the scroll run away. Take out the scrolling of the document and it works fine, just without this scrolling of the page I want.

Any ideas?

Thank!

+3
source share
3 answers

Here is a bug report, not yet fixed: http://bugs.jqueryui.com/ticket/5009

jQuery UI , 1.9. , , : jQuery draggable

+5

, drag (fires onmousemove) . - , ui.item ui.helper.

drag: function(event, ui) { 
    var offset = $(this).offset();
    var yPos = offset.top; 
    ui.helper.css('margin-top', $(window).scrollTop() + 'px');
}

, Chrome Safari. Mozilla , . IE.

+1

. , .

drag: function(event, ui) { 
    ui.helper.css('margin-top', -(t-c.scrollTop()));
},
start: function( event, ui ) {
    t = c.scrollTop();
},
0

All Articles