krista-m
8/27/2018 - 9:56 PM

Fixed navigation on scroll

Show a fixed navigation when scrolling on a page

var kristaraeStarter = ( function( $ ) {
 
  // Add stick nav on scroll
	$(window).scroll( function(event) {
        var scroll = $(this).scrollTop();
        var wrap = $("body");

        if (scroll > 150) {
            wrap.addClass("scrolling");
        } else {
            wrap.removeClass("scrolling");
        }

	});

})( jQuery );

jQuery( window ).on( 'load', kristaraeStarter.init );
/**
 * File switch-navigation.js.
 *
 * Handles toggling the displayed navigation bar and scroll to top button
 */
 
 var $j = jQuery.noConflict();
 $j( function() {

 	$j(window).scroll( function(event) {

 		var scroll = $j(this).scrollTop();

	if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) {
 		$j('.menu-wrapper').css('display', 'block');
 		$j('.nav-secondary').css('display', 'none');
	} else {
 		if ( scroll > 260 ) {
 			$j('.menu-wrapper').css('display', 'block');
 			$j('.nav-secondary').css('display', 'none');
 			$j('.scroll-to-top').css('display', 'inline-block');
 		} else {
 			$j('.menu-wrapper').css('display', 'none');
 			$j('.nav-secondary').css('display', 'block');
 			$j('.scroll-to-top').css('display', 'none');
 		}
	}

 		// Move the scroll to top button up a little if we're scrolled to the bottom of the page
 		// if ( $j(this).scrollTop() + $j(window).height() == $j(document).height()) {
 		// 	$j('.scroll-to-top').css('bottom', '113px');
 		// } else {
 		// 	$j('.scroll-to-top').css('bottom', '20px');

 		// }

 	});

 });