Search and Top Navigation
#3868 closed bug (fixed)
Opened January 18, 2009 06:51PM UTC
Closed January 23, 2009 01:10PM UTC
Last modified October 11, 2012 09:15PM UTC
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: | ||
Blocked by: | Blocking: |
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;-)
------------------- my customization ----------------
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);
}
}
}
Sorry - I didnt use wiki-format, here is the fix