Merge branch 'develop' into stats-profile

This commit is contained in:
Konstantinos Triantafyllou 2023-05-02 18:08:58 +03:00
commit 3b45f2ccb5
1 changed files with 28 additions and 8 deletions

View File

@ -13,7 +13,6 @@ import {
import {LayoutService, SidebarItem} from "../sidebar/layout.service";
declare var UIkit;
declare var ResizeObserver;
@Component({
selector: '[page-content]',
@ -99,11 +98,9 @@ export class PageContentComponent implements OnInit, AfterViewInit, OnDestroy {
ngAfterViewInit() {
if (typeof document !== "undefined") {
this.observeStickyFooter();
if (this.shouldSticky && typeof document !== 'undefined') {
this.sticky.header = UIkit.sticky((this.headerSticky ? this.header.nativeElement : this.actions.nativeElement), {
offset: this.offset
});
this.initHeader();
this.observeStickyHeader();
this.subscriptions.push(UIkit.util.on(document, 'active', '#' + this.sticky.header.$el.id, () => {
this.isStickyActive = true;
this.cdr.detectChanges();
@ -116,6 +113,7 @@ export class PageContentComponent implements OnInit, AfterViewInit, OnDestroy {
if (this.sticky_footer) {
let footer_offset = this.calcStickyFooterOffset(this.sticky_footer.nativeElement);
this.sticky.footer = UIkit.sticky(this.sticky_footer.nativeElement, {bottom: true, offset: footer_offset});
this.observeStickyFooter();
}
}
}
@ -124,12 +122,23 @@ export class PageContentComponent implements OnInit, AfterViewInit, OnDestroy {
this.subscriptions.forEach(subscription => {
if (typeof ResizeObserver !== "undefined" && subscription instanceof ResizeObserver) {
subscription.disconnect();
} else if (typeof ResizeObserver !== "undefined" && subscription instanceof IntersectionObserver) {
} else if (typeof IntersectionObserver !== "undefined" && subscription instanceof IntersectionObserver) {
subscription.disconnect();
}
});
}
initHeader() {
this.sticky.header = UIkit.sticky((this.headerSticky ? this.header.nativeElement : this.actions.nativeElement), {
offset: this.offset
});
}
initFooter() {
let footer_offset = this.calcStickyFooterOffset(this.sticky_footer.nativeElement);
this.sticky.footer = UIkit.sticky(this.sticky_footer.nativeElement, {bottom: true, offset: footer_offset});
}
/**
* Workaround for sticky not update bug when sidebar is toggled.
@ -200,14 +209,25 @@ export class PageContentComponent implements OnInit, AfterViewInit, OnDestroy {
headerObs.observe(this.header.nativeElement);
}
}
private observeStickyHeader() {
if (this.sticky.header) {
let resizeObs= new ResizeObserver(entries => {
entries.forEach(entry => {
this.initHeader();
})
});
this.subscriptions.push(resizeObs);
resizeObs.observe(this.sticky.header.$el);
}
}
private observeStickyFooter() {
if (this.sticky_footer) {
let resizeObs = new ResizeObserver(entries => {
entries.forEach(entry => {
setTimeout(() => {
this.sticky.footer.offset = this.calcStickyFooterOffset(entry.target);
this.cdr.detectChanges();
this.initFooter();
});
})
});