Browse: Home / Snippets /

Hook in pagination JS hook

Contents


Snippet #

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 );