Add perPage functionality
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
export function getNextItemIndexLimited(currentItemIndex, items) {
|
||||
return Math.min(currentItemIndex + 1, items.length - 1)
|
||||
export function getNextItemIndexLimited(currentItemIndex, length) {
|
||||
return Math.min(currentItemIndex + 1, length - 1)
|
||||
}
|
||||
|
||||
export function getNextItemIndexInfinte(currentItemIndex, items) {
|
||||
export function getNextItemIndexInfinte(currentItemIndex, length) {
|
||||
const newCurrentItemIndex = currentItemIndex + 1
|
||||
return newCurrentItemIndex > items.length - 1 ? 0 : newCurrentItemIndex
|
||||
return newCurrentItemIndex > length - 1 ? 0 : newCurrentItemIndex
|
||||
}
|
||||
|
||||
export function getNextItemIndexFn(infinite) {
|
||||
return infinite ? getNextItemIndexInfinte : getNextItemIndexLimited
|
||||
}
|
||||
|
||||
export function getPrevItemIndexLimited(currentItemIndex, items) {
|
||||
export function getPrevItemIndexLimited(currentItemIndex, length) {
|
||||
return Math.max(currentItemIndex - 1, 0)
|
||||
}
|
||||
|
||||
export function getPrevItemIndexInfinte(currentItemIndex, items) {
|
||||
export function getPrevItemIndexInfinte(currentItemIndex, length) {
|
||||
const newCurrentItemIndex = currentItemIndex - 1
|
||||
return newCurrentItemIndex >= 0 ? newCurrentItemIndex : items.length - 1
|
||||
return newCurrentItemIndex >= 0 ? newCurrentItemIndex : length - 1
|
||||
}
|
||||
|
||||
export function getPrevItemIndexFn(infinite) {
|
||||
|
||||
Reference in New Issue
Block a user