[TIP] Scroll to top of page on AJAX pagination.
-
This simply scrolls to the top of the page when navigating gallery pages with AJAX enabled. I was surprised to find it wasn’t an option as you don’t really want to stay at the bottom of the page when you want to view the next page of photos. Add this to a custom JS file or wrap it in
<script></script>
tags infooter.php
or the PHP file of the page with the gallery.jQuery(document).ready(function($) { $('HIGHER_DOM_ELEMENT').on('click', '.ngg-navigation a', function(event) { $('html,body').animate({scrollTop:0}, 1000); }); }
Replace
HIGHER_DOM_ELEMENT
with a selector of an element higher in the DOM. For example, I have the gallery wrapped with adiv
with the ID ofgallery-wrapper
, so I would replace it with#gallery-wrapper
. If you don’t want to add to the PHP code, you can usebody
.
- The topic ‘[TIP] Scroll to top of page on AJAX pagination.’ is closed to new replies.