Fixed media picker autoscroll

This commit is contained in:
Djamil Legato
2018-01-09 17:38:53 -08:00
parent a8dc3d724b
commit 70d5b369eb
3 changed files with 20 additions and 7 deletions

View File

@@ -15,6 +15,9 @@ $(function() {
cards.each(function() { cards.each(function() {
$(this).css('width', width); $(this).css('width', width);
}); });
treescroll.update();
thumbscroll.update();
}); });
$(document).on('opened', '.remodal', function() { $(document).on('opened', '.remodal', function() {

View File

@@ -114,7 +114,7 @@ var filterFiles = function filterFiles() {
files_ended = false; files_ended = false;
$('.empty-space').remove(); $('.empty-space').remove();
loadMedia(filters, function(content) { loadMedia(filters, function(content) {
if (!$(content).length) { if (!content.trim().length) {
showEmptyState(); showEmptyState();
} else { } else {
if (!filters.page && (!filters.date || filters.date === '*') && (!filters.type || filters.type === '*')) { if (!filters.page && (!filters.date || filters.date === '*') && (!filters.type || filters.type === '*')) {
@@ -164,8 +164,15 @@ $('body').on('click', '.js__reset-pages-filter', (event) => {
/* handle infinite loading */ /* handle infinite loading */
var enableInfiniteScrolling = function enableInfiniteScrolling() { var enableInfiniteScrolling = function enableInfiniteScrolling() {
$('.spinning-wheel').hide(); $('.spinning-wheel').hide();
var view = $('.mediapicker-scroll'); var view = $('.mediapicker-scroll').last();
view.scroll(function() { var gemini = view.data('scrollbar');
if (gemini) {
gemini = gemini.getViewElement();
}
if (!gemini.length && !view.length) { return; }
$(gemini || view).on('scroll', function() {
if (($(this).scrollTop() + $(this).innerHeight() + 100) >= $(this)[0].scrollHeight) { if (($(this).scrollTop() + $(this).innerHeight() + 100) >= $(this)[0].scrollHeight) {
fillView(); fillView();
} }
@@ -185,6 +192,8 @@ var loadNextBatch = function loadNextBatch(callback) {
callback(); callback();
} }
} }
$('.media-container .media-range').trigger('input');
}); });
}; };
@@ -197,7 +206,8 @@ var fillView = function fillView() {
return; return;
} }
if ($('.js__files').find('.card-item').last().offset().top < $('.media-container').height()) {
if ($('.js__files').find('.card-item').last().offset().top - 1 <= $('.media-container').height()) {
loadNextBatch(function() { loadNextBatch(function() {
fillView(); fillView();
}); });

File diff suppressed because one or more lines are too long