Calculate # of items to show on a slide page

I have a number of items that need to be displayed to a user. The items are categories into sections. The list is dynamic but small (3 pages at most). I need to figure calculate how many items can fit on a page. If a category is split between pages, I need to show the header on the next page as well. There can’t be any scrolling and the height of the items could vary.

I plan to use ionslides for the pagination and flex box to layout the items within a category.

I am new to ionic and am not sure where to get started?

Page 1
Category 1 header
Flex box with wrapping
Category 2 header
Flex box with wrapping

Page 2
Category 2 header cont…
Flex box with wrapping (remainder of category 2 items)