import type { Page , PerPage } from '@kbn/securitysolution-io-ts-list-types' ; interface CalculateScrollMathOptions { perPage : PerPage ; page : Page ; hopSize : number ; currentIndexPosition : number ; } interface CalculateScrollMathReturn { hops : number ; leftOverAfterHops : number ; } export const calculateScrollMath = ( { currentIndexPosition , page , perPage , hopSize , } ) : CalculateScrollMathReturn => { const startPageIndex = ( page - 1 ) * perPage - currentIndexPosition ; if ( startPageIndex < 0 ) { throw new Error ( `page: ${ page }, perPage ${ perPage } and currentIndex ${ currentIndexPosition } are less than zero` ) ; } const hops = Math . floor ( startPageIndex / hopSize ) ; const leftOverAfterHops = startPageIndex - hops * hopSize ; return { hops , leftOverAfterHops , } ; } ;