@s-ui/react-molecule-pagination
Version:
`MoleculePagination` is a component that displays a range of pages with the current page highlighted and the proper buttons to navigate across the available pages in the entire range of total pages
17 lines • 760 B
JavaScript
/**
* Gets the highest number of the range assigned for the page number according to the number of pages to display
* @param {object} params - parameters pagination
* @param {number} params.page - Original page number
* @param {number} params.totalPages - Total number of pages
* @param {number} params.showPages - Number of pages to display in the range of pages displayed
* @return {number} highest number of the assigned range for the page
*/
var highRange = function highRange(_ref) {
var page = _ref.page,
totalPages = _ref.totalPages,
showPages = _ref.showPages;
var highest = page + (showPages - page % showPages);
if (page % showPages) return highest < totalPages ? highest : totalPages;
return page;
};
export default highRange;