Browse: Home / Snippets /

Hook in pagination JS hook

Contents


Snippet #

Important: All snippets are provided as-is without support or guarantees. These snippets are provided as guidelines for advanced users looking to customize LearnDash. For any additional help or support with these snippets, we recommend reaching out to a LearnDash Expert.

add_action( 'wp_footer', function() {
	?>
	<script>
	//jQuery(document).ready(function() {
		jQuery(window).on('learndash_pager_content_changed', function (e, args) {
			if ( typeof args['parent_div'] !== 'undefined') {

				var win = jQuery(window);
				var winScrollPosition = win.scrollTop();
				var objOffsetTop = jQuery(args['parent_div']).offset().top;

				if (winScrollPosition > objOffsetTop) {
					jQuery('html,body').animate({
						scrollTop: objOffsetTop
					}, 750);
				}

				jQuery(window).trigger('resize');
			}	
		});	
	//});
	</script>
	<?php
}, 999 );