Fixed two pagination bugs

1. The onPageChange callback is triggered right after page refresh,
which it shouldn't. The expectation is that we consider a page is
changing after the page has loaded, and we take an action to change
the page, like using the navigation.

2. generatePagesArray should NOT always consider 1 as the current page
For example, if we want to keep the url and current page in sync, and we
access the page at url?page=5, we want to generated the pagination based on
the current page, which is 5.