mirror of
https://github.com/zombieFox/nightTab.git
synced 2024-12-27 17:19:05 +01:00
[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);
|
}, 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",
|
||||||
|
Loading…
Reference in New Issue
Block a user