Fix bug with gallery count with swipe

Fixes issue noticed by @kaelig with gallery counter displaying incorrect count after swiping back to page.