From 5f86745dbb5c40985565364d768371dbb501f6d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thayn=C3=A3=20Bruno=20Moretti?= Date: Thu, 22 Feb 2018 12:05:07 -0300 Subject: [PATCH 1/2] Fix mobile menu scrolling --- _scss/header/_navbar.scss | 4 ++-- index.html | 12 +++++++++--- js/index.js | 15 ++++++--------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/_scss/header/_navbar.scss b/_scss/header/_navbar.scss index ade38b6..ad6a09b 100644 --- a/_scss/header/_navbar.scss +++ b/_scss/header/_navbar.scss @@ -84,7 +84,7 @@ .nav__items { height: calc(100vh - 64px); max-height: 700px; - overflow-y: scroll; + list-style: none; .subscribe-button { list-style: none; padding: 14px 30px; @@ -169,4 +169,4 @@ @extend .mobile-nav-trigger; background-image: url('../img/closebutton-01.svg'); } -} \ No newline at end of file +} diff --git a/index.html b/index.html index 53ecd9e..8ca9032 100644 --- a/index.html +++ b/index.html @@ -2,8 +2,8 @@ - - + + Python Joinville @@ -16,7 +16,7 @@

Menu

@@ -290,5 +290,11 @@
+ + + diff --git a/js/index.js b/js/index.js index d574f84..c6493f9 100644 --- a/js/index.js +++ b/js/index.js @@ -1,6 +1,3 @@ -import 'scss/index.scss'; -import ScrollTo from 'storm-scroll-to'; - class MobileNavManager { constructor() { this.mobileNav = document.querySelector('#mobile-nav'); @@ -51,8 +48,12 @@ class MobileNavManager { } this.mobileNav.classList.toggle('opened'); this.handleFocus(); + if (e.currentTarget.classList.contains('scroll')) { - e.preventDefault(); + var offset = $($(e.currentTarget).attr('href')).offset() + $('body').stop().animate({ + 'scrollTop': offset.top - $('.header__nav').height() + }, 900); } } @@ -63,8 +64,4 @@ class MobileNavManager { document.addEventListener('DOMContentLoaded', () => { new MobileNavManager(); - ScrollTo.init('.scroll', { - offset: 120, - focus: false, - }); -}); \ No newline at end of file +}); From 4805079444a68662db3404a0a6c8434854579747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thayn=C3=A3=20Bruno=20Moretti?= Date: Thu, 22 Feb 2018 17:47:23 -0300 Subject: [PATCH 2/2] Add menu smooth scroll on desktop version --- js/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/js/index.js b/js/index.js index c6493f9..4b96ae9 100644 --- a/js/index.js +++ b/js/index.js @@ -48,13 +48,6 @@ class MobileNavManager { } this.mobileNav.classList.toggle('opened'); this.handleFocus(); - - if (e.currentTarget.classList.contains('scroll')) { - var offset = $($(e.currentTarget).attr('href')).offset() - $('body').stop().animate({ - 'scrollTop': offset.top - $('.header__nav').height() - }, 900); - } } get isOpened() { @@ -64,4 +57,11 @@ class MobileNavManager { document.addEventListener('DOMContentLoaded', () => { new MobileNavManager(); + + $('.nav__item .nav__anchor').click(function() { + var offset = $($(this).attr('href')).offset() + $('body').stop().animate({ + 'scrollTop': offset.top - $('.header__nav').height() + }, 900); + }) });