Also fixed pagination for negative offsets (refs #54)

This commit is contained in:
Timo Smit 2017-02-04 14:20:18 +01:00
parent f17df67a9b
commit 7484421845

View file

@ -22,10 +22,14 @@ function pagination.calculate(count, limit, offset)
offset = offset or 0
if offset < 0 then
if count < math.abs(offset) then
limit = count
offset = 0
else
limit = math.min(math.abs(offset), 30)
offset = count + offset
end
if limit + offset > count then
elseif limit + offset > count then
limit = count % limit
end