Fix gallery opening

- when there are no images
- when we have scrolled past the last image