[frontend] Fixing spacing logic when nearing the beginning/end of the photo set