Update documentation of pagination methods
This commit is contained in:
parent
e593354cb4
commit
deb95b355f
1 changed files with 8 additions and 5 deletions
|
|
@ -8,6 +8,12 @@ interface Page {
|
||||||
export interface IUsePagination<T> {
|
export interface IUsePagination<T> {
|
||||||
items: T[];
|
items: T[];
|
||||||
changeOffset: (offset: Offset, newValue?: number) => void;
|
changeOffset: (offset: Offset, newValue?: number) => void;
|
||||||
|
/**
|
||||||
|
* Returns an array with the aviables pages to directly navigate.
|
||||||
|
* This pages are centered in the current page and offest to 5 items to each side.
|
||||||
|
|
||||||
|
* @returns {Page}
|
||||||
|
*/
|
||||||
getPaginationRange: () => Page[];
|
getPaginationRange: () => Page[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,10 +95,7 @@ export default function usePagination<T>({
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns an array with the aviables pages to directly navigate.
|
function getPaginationRange(): Page[] {
|
||||||
* This pages are centered in the current page and offest to 5 items to each side.
|
|
||||||
*/
|
|
||||||
const getPaginationRange = (): Page[] => {
|
|
||||||
// NOTE: this is made to work with uneven numbers,
|
// NOTE: this is made to work with uneven numbers,
|
||||||
// So the current page is always aligned in the center.
|
// So the current page is always aligned in the center.
|
||||||
const paginationToSides = 5;
|
const paginationToSides = 5;
|
||||||
|
|
@ -111,7 +114,7 @@ export default function usePagination<T>({
|
||||||
return { page, current: page === currentPage };
|
return { page, current: page === currentPage };
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
changeOffset,
|
changeOffset,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue