Ticket #3868 (closed bug: fixed)

Opened 5 years ago

Last modified 19 months ago

draggable with axis=x will scroll parent also in y-direction if mouse moved downward while dragging

Reported by: gardsted Owned by:
Priority: minor Milestone:
Component: ui.draggable Version: 1.6rc5
Keywords: Cc:
Blocking: Blocked by:

Description

I want the parent scrolled, but only in x-direction (draggable is also only draggable in x-direction)

I enclose below a fix for draggable.drag in current 1.5.3 version.

I don't know If you consider this a bug or not.: Otherwise, I just made a customization:

only changes are:

if(!o.axis
o.axis != "x"){...}

and

if(!o.axis
o.axis != "y"){...}

glad, i could contribute;-)


drag: function(e, ui) {

var o = ui.options; var i = $(this).data("draggable");

if(!o.axis
o.axis != "x"){

if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {

if((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity)

i.overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed;

if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity)

i.overflowY[0].scrollTop = i.overflowY[0].scrollTop - o.scrollSpeed;

} else {

if(e.pageY - $(document).scrollTop() < o.scrollSensitivity)

$(document).scrollTop($(document).scrollTop() - o.scrollSpeed);

if($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity)

$(document).scrollTop($(document).scrollTop() + o.scrollSpeed);

}

}

if(!o.axis
o.axis != "y"){

if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {

if((i.overflowXOffset.left + i.overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity)

i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft + o.scrollSpeed;

if(e.pageX - i.overflowXOffset.left < o.scrollSensitivity)

i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft - o.scrollSpeed;

} else {

if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity)

$(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);

if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity)

$(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);

}

}

}

Change History

comment:1 Changed 5 years ago by gardsted

Sorry - I didnt use wiki-format, here is the fix

    drag: function(e, ui) {

        var o = ui.options;
        var i = $(this).data("draggable");

        if(!o.axis || o.axis != "x"){
            if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {
                if((i.overflowYOffset.top + i.overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity)
                    i.overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed;
                if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity)
                    i.overflowY[0].scrollTop = i.overflowY[0].scrollTop - o.scrollSpeed;

            } else {
                if(e.pageY - $(document).scrollTop() < o.scrollSensitivity)
                    $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
                if($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity)
                    $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
            }
        }

        if(!o.axis || o.axis != "y"){
            if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {
                if((i.overflowXOffset.left + i.overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity)
                    i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft + o.scrollSpeed;
                if(e.pageX - i.overflowXOffset.left < o.scrollSensitivity)
                    i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft - o.scrollSpeed;
            } else {
                if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity)
                    $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
                if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
                    $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
            }
        }
    }

comment:2 Changed 5 years ago by paul

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in r1765. Thanks!

comment:3 Changed 19 months ago by scott.gonzalez

  • Milestone TBD deleted

Milestone TBD deleted

Note: See TracTickets for help on using tickets.