From 2c79e52c6edf0b81004199e436a8e126926781dc Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Tue, 15 Aug 2017 08:53:20 -0400 Subject: [PATCH] Page was scrolling 30px more on submenu clicks than main nav clicks --- assets/js/global.js | 12 +++++++++--- assets/js/navigation.js | 29 ++++++++++++++++++----------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/assets/js/global.js b/assets/js/global.js index a7b54d1..5b2d40a 100755 --- a/assets/js/global.js +++ b/assets/js/global.js @@ -192,9 +192,15 @@ var scrollTarget = $($(this).attr("href")); // console.log(scrollTarget); if (scrollTarget) { - $('body, html').animate({ - scrollTop: scrollTarget.offset().top-90 - }, 300); + if ($(window).width() > 1280) { + $('body, html').animate({ + scrollTop: scrollTarget.offset().top-90 + }, 300); + } else { + $('body, html').animate({ + scrollTop: scrollTarget.offset().top-120 + }, 300); + } } target = $(this).attr('id').split("-")[1]; parent_target = $(this).parents('.parent-container').attr('id').split("-")[1]; diff --git a/assets/js/navigation.js b/assets/js/navigation.js index c85f414..e8c7bcb 100755 --- a/assets/js/navigation.js +++ b/assets/js/navigation.js @@ -126,35 +126,42 @@ $(".static-nav-link").click(function(e) { e.preventDefault(); var scrollTarget = $($(this).attr("href")); -// console.log(scrollTarget); if (scrollTarget) { - $('body, html').animate({ - scrollTop: scrollTarget.offset().top-120 - }, 300); + if ($(window).width() > 1280) { + $('body, html').animate({ + scrollTop: scrollTarget.offset().top-90 + }, 300); + } else { + $('body, html').animate({ + scrollTop: scrollTarget.offset().top-120 + }, 300); + } } }); $(".static-home-link").click(function(e) { e.preventDefault(); var scrollTarget = $('.home'); -// console.log(scrollTarget); if (scrollTarget) { - $('body, html').animate({ - scrollTop: scrollTarget.offset().top-120 - }, 300); + if ($(window).width() > 1280) { + $('body, html').animate({ + scrollTop: scrollTarget.offset().top-90 + }, 300); + } else { + $('body, html').animate({ + scrollTop: scrollTarget.offset().top-120 + }, 300); + } } }); function setActiveNavItem() { - console.log("here"); $(".nav-parent").each(function() { if ( $('.top-nav-right-list a[href="#' + $(this).attr("id") +'"]').not(".active") ) { if(myTopPosition > $(this).offset().top && ( $(this).offset().top + $(this).next().outerHeight() > myTopPosition-90) ) { - $('.top-nav-right-list a[href="#' + $(this).attr("id") +'"]').addClass("active"); } else { - //console.log("no"); $('.top-nav-right-list a[href="#' + $(this).attr("id") +'"]').removeClass("active"); } } -- 2.17.1