Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ------------------------------------------------------------------------ */
- /* NAV
- /* ------------------------------------------------------------------------ */
- $('.nav-toggle').click(function(){
- $('.main-sidebar').toggleClass('toggle-on');
- $('.section-wrapper').toggleClass('toggle-on');
- });
- function initNav() {
- var navSpaceHeight = getNavSpaceHeight();
- $('.top-line').css('height', navSpaceHeight);
- $('.bottom-line').css('height', navSpaceHeight);
- }
- initNav();
- $(window).on('resize', function () {
- initNav();
- });
- $('.navigation a').click(function(){
- var target = $(this).data('target');
- $.scrollTo( target, 1300, {easing:'swing'} );
- $('.navigation a').removeClass('current');
- $('.navigation li').removeClass('current');
- $(this).addClass('current');
- $(this).parent('li').addClass('current');
- });
- // Window scroll
- $(window).scroll(function() {
- var windscroll = $(window).scrollTop();
- if (windscroll >= 100) {
- $('body section').each(function(i) {
- if ($(this).position().top <= windscroll - 0) {
- $('.navigation a.current').parent('li').removeClass('current');
- $('.navigation a.current').removeClass('current');
- $('.navigation a').eq(i).addClass('current');
- $('.navigation a.current').parent('li').addClass('current');
- }
- });
- } else {
- $('.navigation a.current').removeClass('current');
- $('.navigation a.current').parent('li').removeClass('current');
- $('.navigation a:first').parent('li').addClass('current');
- $('.navigation a:first').addClass('current');
- }
- }).scroll();
- $(document).keydown(function(e) {
- var code = e.keyCode || e.which;
- if(code == 38) { // Up
- var $next = $( '.navigation' ).find( '.current' ).prev( 'li' ).find('a');
- // If there isn't one, go to the beginning
- if ( ! $next.length ) {
- $next = $( '.navigation' ).find( 'li' ).last().find('a')
- }
- // Trigger the click
- $next.trigger( 'click' );
- } else if(code == 40) { // Down
- var $next = $( '.navigation' ).find( '.current' ).next( 'li' ).find('a');
- // If there isn't one, go to the beginning
- if ( ! $next.length ) {
- $next = $( '.navigation' ).find( 'li' ).first().find('a')
- }
- // Trigger the click
- $next.trigger( 'click' );
- }
- });
- /* ------------------------------------------------------------------------ */
- /* SMOOTH SCROLL
- /* ------------------------------------------------------------------------ */
- var scrollAnimationTime = 1300,
- scrollAnimation = 'swing';
- $('a.scrollto').bind('click.smoothscroll',function (event) {
- event.preventDefault();
- var target = this.hash;
- $('html, body').stop().animate({
- 'scrollTop': $(target).offset().top
- }, scrollAnimationTime, scrollAnimation, function () {
- window.location.hash = target;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement