From d7598eb3508df0aeb30cebd447513fe95f91e104 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Tue, 8 Mar 2022 20:35:00 +0200 Subject: [PATCH] Change page-content to be sticky on scroll up --- .../page-content/page-content.component.ts | 25 ++----------------- sharedComponents/navigationBar.component.html | 4 +-- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/dashboard/sharedComponents/page-content/page-content.component.ts b/dashboard/sharedComponents/page-content/page-content.component.ts index 7b9ce16e..2803fd79 100644 --- a/dashboard/sharedComponents/page-content/page-content.component.ts +++ b/dashboard/sharedComponents/page-content/page-content.component.ts @@ -15,31 +15,10 @@ import {ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit} from "@an ` }) -export class PageContentComponent implements OnInit, OnDestroy{ - private current; +export class PageContentComponent implements OnInit{ public offset: string; - constructor(private cdr: ChangeDetectorRef) { - } - - @HostListener('window:scroll', ['$event.target']) // for window scroll events - scroll(e) { - let scroll = e.scrollingElement.scrollTop; - if (scroll > this.current) { - this.offset = '0'; - } else { - this.offset = getComputedStyle(document.documentElement).getPropertyValue('--structure-header-height'); - } - this.current = scroll; - this.cdr.detectChanges(); - } - ngOnInit() { - if(typeof window !== "undefined") { - this.current = window.pageYOffset; - } - } - - ngOnDestroy() { + this.offset = getComputedStyle(document.documentElement).getPropertyValue('--structure-header-height'); } } diff --git a/sharedComponents/navigationBar.component.html b/sharedComponents/navigationBar.component.html index 5da75016..b4f0da3f 100644 --- a/sharedComponents/navigationBar.component.html +++ b/sharedComponents/navigationBar.component.html @@ -266,7 +266,7 @@ + class="uk-width-1-1">

{{header.title}}

@@ -278,7 +278,7 @@ + class="uk-width-1-1">

{{header.title}}