|
|
|
|
|
|
|
|
|
export function finite({ active, pageSize, total, }) { |
|
const middle = Math.floor(pageSize / 2); |
|
if (total <= pageSize || active < middle) |
|
return active; |
|
if (active >= total - middle) |
|
return active + pageSize - total; |
|
return middle; |
|
} |
|
|
|
|
|
|
|
|
|
export function infinite({ active, lastActive, total, pageSize, pointer, }) { |
|
if (total <= pageSize) |
|
return active; |
|
|
|
|
|
if (lastActive < active && active - lastActive < pageSize) { |
|
|
|
return Math.min(Math.floor(pageSize / 2), pointer + active - lastActive); |
|
} |
|
return pointer; |
|
} |
|
|