Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scrolling when dragging files. Fixes #12329 #22576

Merged
merged 10 commits into from
May 20, 2016
21 changes: 21 additions & 0 deletions apps/files/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ var dragOptions={
cursorAt: { left: 24, top: 18 },
helper: createDragShadow,
cursor: 'move',

start: function(event, ui){
var $selectedFiles = $('td.filename input:checkbox:checked');
if (!$selectedFiles.length) {
Expand All @@ -398,6 +399,26 @@ var dragOptions={
$selectedFiles = $(this);
}
$selectedFiles.closest('tr').fadeTo(250, 1).removeClass('dragging');
},
drag: function(event, ui) {
var scrollingArea = FileList.$container;
var currentScrollTop = $(scrollingArea).scrollTop();
var scrollArea = Math.min(Math.floor($(window).innerHeight() / 2), 100);

var bottom = $(window).innerHeight() - scrollArea;
var top = $(window).scrollTop() + scrollArea;
if (event.pageY < top) {
$('html, body').animate({

scrollTop: $(scrollingArea).scrollTop(currentScrollTop - 10)
}, 400);

} else if (event.pageY > bottom) {
$('html, body').animate({
scrollTop: $(scrollingArea).scrollTop(currentScrollTop + 10)
}, 400);
}

}
};
// sane browsers support using the distance option
Expand Down