[refactor] improve menu state when opening and tabbing
This commit is contained in:
parent
a5590edf39
commit
d14eb298f1
15
js/menu.js
15
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",
|
||||
|
|
Loading…
Reference in New Issue