[refactor] improve menu state when opening and tabbing

This commit is contained in:
Kuldeep M 2019-02-18 15:33:25 +00:00
parent a5590edf39
commit d14eb298f1
1 changed files with 9 additions and 6 deletions

View File

@ -14,13 +14,16 @@ var menu = (function() {
}, false); }, false);
}; };
var _scrollToTop = function(element) { var _scrollToTop = function() {
element.scrollTop = 0; if (window.innerWidth < 550) {
helper.e(".menu-area").scrollTop = 0;
} else {
helper.e(".menu-content").scrollTop = 0;
};
}; };
var _tab = function(button) { var _tab = function(button) {
var allMenuNavButton = helper.eA(".menu-nav-button"); var allMenuNavButton = helper.eA(".menu-nav-button");
var menuContent = helper.e(".menu-content");
var allMenuContentArea = helper.eA(".menu-content-area"); var allMenuContentArea = helper.eA(".menu-content-area");
var target = helper.e(button.dataset.target); var target = helper.e(button.dataset.target);
allMenuNavButton.forEach(function(arrayItem, index) { allMenuNavButton.forEach(function(arrayItem, index) {
@ -31,7 +34,7 @@ var menu = (function() {
}); });
helper.addClass(button, "active"); helper.addClass(button, "active");
helper.removeClass(target, "is-hidden"); helper.removeClass(target, "is-hidden");
_scrollToTop(menuContent); _scrollToTop();
}; };
var close = function() { var close = function() {
@ -44,7 +47,7 @@ var menu = (function() {
}; };
var open = function() { var open = function() {
_scrollToTop(helper.e(".menu-content")); _scrollToTop();
helper.setObject({ helper.setObject({
object: state.get(), object: state.get(),
path: "menu", path: "menu",
@ -61,7 +64,7 @@ var menu = (function() {
newValue: false newValue: false
}); });
} else { } else {
_scrollToTop(helper.e(".menu-content")); _scrollToTop();
helper.setObject({ helper.setObject({
object: state.get(), object: state.get(),
path: "menu", path: "menu",