From d14eb298f1d18b3af3e68c843898f69fccfeaf08 Mon Sep 17 00:00:00 2001 From: Kuldeep M Date: Mon, 18 Feb 2019 15:33:25 +0000 Subject: [PATCH] [refactor] improve menu state when opening and tabbing --- js/menu.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/js/menu.js b/js/menu.js index a075aac5..d55cf58a 100644 --- a/js/menu.js +++ b/js/menu.js @@ -14,13 +14,16 @@ var menu = (function() { }, false); }; - var _scrollToTop = function(element) { - element.scrollTop = 0; + var _scrollToTop = function() { + if (window.innerWidth < 550) { + helper.e(".menu-area").scrollTop = 0; + } else { + helper.e(".menu-content").scrollTop = 0; + }; }; var _tab = function(button) { var allMenuNavButton = helper.eA(".menu-nav-button"); - var menuContent = helper.e(".menu-content"); var allMenuContentArea = helper.eA(".menu-content-area"); var target = helper.e(button.dataset.target); allMenuNavButton.forEach(function(arrayItem, index) { @@ -31,7 +34,7 @@ var menu = (function() { }); helper.addClass(button, "active"); helper.removeClass(target, "is-hidden"); - _scrollToTop(menuContent); + _scrollToTop(); }; var close = function() { @@ -44,7 +47,7 @@ var menu = (function() { }; var open = function() { - _scrollToTop(helper.e(".menu-content")); + _scrollToTop(); helper.setObject({ object: state.get(), path: "menu", @@ -61,7 +64,7 @@ var menu = (function() { newValue: false }); } else { - _scrollToTop(helper.e(".menu-content")); + _scrollToTop(); helper.setObject({ object: state.get(), path: "menu",