[feature] scroll menu content to top when navigating tabs

This commit is contained in:
zombieFox 2019-01-26 16:53:09 +00:00
parent ccc4060f64
commit 1aa93166c5
3 changed files with 10 additions and 2 deletions

View File

@ -7,7 +7,7 @@
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
transition: background-color var(--animation-speed-fast) ease-in-out; transition: background-color var(--animation-speed-slow) ease-in-out;
} }
.header-background { .header-background {

View File

@ -14,8 +14,13 @@ var menu = (function() {
}, false); }, false);
}; };
var _scrollToTop = function(element) {
element.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) {
@ -26,6 +31,7 @@ var menu = (function() {
}); });
helper.addClass(button, "active"); helper.addClass(button, "active");
helper.removeClass(target, "is-hidden"); helper.removeClass(target, "is-hidden");
_scrollToTop(menuContent);
}; };
var close = function() { var close = function() {
@ -34,6 +40,7 @@ var menu = (function() {
}; };
var open = function() { var open = function() {
_scrollToTop(helper.e(".menu-content"));
state.get().menu.active = true; state.get().menu.active = true;
render(); render();
}; };
@ -42,6 +49,7 @@ var menu = (function() {
if (state.get().menu.active) { if (state.get().menu.active) {
state.get().menu.active = false; state.get().menu.active = false;
} else { } else {
_scrollToTop(helper.e(".menu-content"));
state.get().menu.active = true; state.get().menu.active = true;
}; };
render(); render();

View File

@ -1,7 +1,7 @@
var version = (function() { var version = (function() {
// version is normally bumped when the state needs changing or any new functionality is added // version is normally bumped when the state needs changing or any new functionality is added
var current = "2.5.0"; var current = "2.6.0";
var get = function() { var get = function() {
var number = current.split("."); var number = current.split(".");