Skip to content
Snippets Groups Projects
Commit 7ffa0de5 authored by Tögl, Christina's avatar Tögl, Christina
Browse files

Replace hardcoded values and fix overflow calculation

parent 993fcbf4
No related branches found
No related tags found
1 merge request!12Add scrollbar to menu if necessary
Pipeline #14702 failed
...@@ -56,7 +56,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) { ...@@ -56,7 +56,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
this.basePath = '/'; this.basePath = '/';
this.keycloakConfig = null; this.keycloakConfig = null;
this.noWelcomePage = false; this.noWelcomePage = false;
this.isMenuOverflow = null; this.menuHeight = -1;
this._updateAuth = this._updateAuth.bind(this); this._updateAuth = this._updateAuth.bind(this);
this._loginStatus = 'unknown'; this._loginStatus = 'unknown';
...@@ -241,8 +241,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) { ...@@ -241,8 +241,7 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
noWelcomePage: { type: Boolean, attribute: "no-welcome-page" }, noWelcomePage: { type: Boolean, attribute: "no-welcome-page" },
shellName: { type: String, attribute: "shell-name" }, shellName: { type: String, attribute: "shell-name" },
shellSubname: { type: String, attribute: "shell-subname" }, shellSubname: { type: String, attribute: "shell-subname" },
noBrand: { type: Boolean, attribute: "no-brand" }, noBrand: { type: Boolean, attribute: "no-brand" }
isMenuOverflow: { type: Boolean, attribute: false }
}; };
} }
...@@ -400,35 +399,29 @@ export class AppShell extends ScopedElementsMixin(LitElement) { ...@@ -400,35 +399,29 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
toggleMenu() { toggleMenu() {
const menu = this.shadowRoot.querySelector("ul.menu"); const menu = this.shadowRoot.querySelector("ul.menu");
const subtitle = this.shadowRoot.querySelector("h2.subtitle");
if (menu === null) { if (menu === null || subtitle === null) {
return; return;
} }
menu.classList.toggle('hidden'); menu.classList.toggle('hidden');
if (this.isMenuOverflow === null) { if (this.menuHeight === -1) {
if (menu.clientHeight >= window.innerHeight) { this.menuHeight = menu.clientHeight;
this.isMenuOverflow = true;
} else {
this.isMenuOverflow = false;
}
} }
if (this.isMenuOverflow && !menu.classList.contains('hidden')) { let topValue = subtitle.getBoundingClientRect().bottom;
// default value if menu is in sticky position let isMenuOverflow = this.menuHeight + topValue >= window.innerHeight ? true : false;
let topValue = 45.5;
// if menu is not in sticky position the top value must be calculated if (isMenuOverflow && !menu.classList.contains('hidden')) {
if (window.pageYOffset < 96) { menu.setAttribute('style', 'position: fixed;top: ' + topValue + 'px;bottom: 0;border-bottom: 0;overflow-y: auto;');
topValue = 141.5 - window.pageYOffset;
}
menu.setAttribute('style', 'position: fixed;top: ' + topValue + 'px;bottom: 0;border-bottom: 0;');
menu.scrollTop = 0; menu.scrollTop = 0;
document.body.setAttribute('style', 'overflow:hidden;'); document.body.setAttribute('style', 'overflow:hidden;');
} else if (this.isMenuOverflow && menu.classList.contains('hidden')) { } else if (isMenuOverflow && menu.classList.contains('hidden')) {
document.body.removeAttribute('style', 'overflow:hidden;'); document.body.removeAttribute('style', 'overflow:hidden;');
menu.setAttribute('style', 'position: fixed;top: ' + topValue + 'px;bottom: 0;border-bottom: 0;overflow-y: auto;');
} }
const chevron = this.shadowRoot.querySelector("#menu-chevron-icon"); const chevron = this.shadowRoot.querySelector("#menu-chevron-icon");
...@@ -660,7 +653,6 @@ export class AppShell extends ScopedElementsMixin(LitElement) { ...@@ -660,7 +653,6 @@ export class AppShell extends ScopedElementsMixin(LitElement) {
position: absolute; position: absolute;
background-color: white; background-color: white;
z-index: 10; z-index: 10;
overflow-y: auto;
} }
.menu li { .menu li {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment