suhiminain
8/30/2018 - 6:58 AM

Fixed navigation on scroll

Show a fixed navigation when scrolling on a page.

thanks . https://snippets.cacher.io/snippet/962e64f03806fd5415bf

/**
 * 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');

 		// }

 	});

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