[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);
};
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",