Skip to content

Commit

Permalink
fixed limit calculation for last page query
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Sep 26, 2018
1 parent eecb81c commit 633c0f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Lists/DefaultList.php
Expand Up @@ -352,10 +352,11 @@ public function splitResults($offset, $total, $limit, $randomSeed = null): ?arra
// Set limit and offset
$limit = $listConfig->perPage;
$offset += (max($page, 1) - 1) * $listConfig->perPage;
$skip = (int) $listConfig->skipFirst;

// Overall limit
if ($offset + $limit > $offsettedTotal) {
$limit = $offsettedTotal - $offset;
if ($offset + $limit > $offsettedTotal + $skip) {
$limit = $offsettedTotal + $skip - $offset;
}

// Add the pagination menu
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/public/js/jquery.list-bundle.es6.js
Expand Up @@ -10,6 +10,7 @@ let jQuery = require('jquery');
$('.huh-list .ajax-pagination').each(function() {
import(/* webpackChunkName: "jscroll" */ 'jscroll').then(() =>
{
let event = new Event('huh_list_pagination_loaded');
let $list = $(this).closest('.huh-list'),
$items = $list.find('.items'),
$wrapper = $list.find('.wrapper'),
Expand Down Expand Up @@ -74,6 +75,8 @@ let jQuery = require('jquery');
{
$item.addClass('last');
}

$items[0].dispatchEvent(event);
});

$jscrollAdded.find('.ajax-pagination').appendTo($jscrollAdded.closest('.jscroll-inner'));
Expand Down

0 comments on commit 633c0f6

Please sign in to comment.