Fix bug in sidebar toggle item | Page content: Add timeout on initialization of header.
This commit is contained in:
parent
bd87a47795
commit
c321390ccb
|
@ -98,23 +98,25 @@ export class PageContentComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
if (typeof document !== "undefined") {
|
if (typeof document !== "undefined") {
|
||||||
if (this.shouldSticky && typeof document !== 'undefined') {
|
|
||||||
this.initHeader();
|
|
||||||
this.observeStickyHeader();
|
|
||||||
this.subscriptions.push(UIkit.util.on(document, 'active', '#' + this.sticky.header.$el.id, () => {
|
|
||||||
this.isStickyActive = true;
|
|
||||||
this.cdr.detectChanges();
|
|
||||||
}));
|
|
||||||
this.subscriptions.push(UIkit.util.on(document, 'inactive', '#' + this.sticky.header.$el.id, () => {
|
|
||||||
this.isStickyActive = false;
|
|
||||||
this.cdr.detectChanges();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
if (this.sticky_footer) {
|
if (this.sticky_footer) {
|
||||||
let footer_offset = this.calcStickyFooterOffset(this.sticky_footer.nativeElement);
|
this.initFooter();
|
||||||
this.sticky.footer = UIkit.sticky(this.sticky_footer.nativeElement, {bottom: true, offset: footer_offset});
|
|
||||||
this.observeStickyFooter();
|
this.observeStickyFooter();
|
||||||
}
|
}
|
||||||
|
if (this.shouldSticky && typeof document !== 'undefined') {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.sticky.header = UIkit.sticky((this.headerSticky ? this.header.nativeElement : this.actions.nativeElement), {
|
||||||
|
offset: this.offset
|
||||||
|
});
|
||||||
|
this.subscriptions.push(UIkit.util.on(document, 'active', '#' + this.sticky.header.$el.id, () => {
|
||||||
|
this.isStickyActive = true;
|
||||||
|
this.cdr.detectChanges();
|
||||||
|
}));
|
||||||
|
this.subscriptions.push(UIkit.util.on(document, 'inactive', '#' + this.sticky.header.$el.id, () => {
|
||||||
|
this.isStickyActive = false;
|
||||||
|
this.cdr.detectChanges();
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,13 +130,6 @@ export class PageContentComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initHeader() {
|
|
||||||
this.sticky.header = UIkit.sticky((this.headerSticky ? this.header.nativeElement : this.actions.nativeElement), {
|
|
||||||
offset: this.offset
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
initFooter() {
|
initFooter() {
|
||||||
let footer_offset = this.calcStickyFooterOffset(this.sticky_footer.nativeElement);
|
let footer_offset = this.calcStickyFooterOffset(this.sticky_footer.nativeElement);
|
||||||
this.sticky.footer = UIkit.sticky(this.sticky_footer.nativeElement, {bottom: true, offset: footer_offset});
|
this.sticky.footer = UIkit.sticky(this.sticky_footer.nativeElement, {bottom: true, offset: footer_offset});
|
||||||
|
@ -210,18 +205,6 @@ export class PageContentComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
private observeStickyFooter() {
|
||||||
if (this.sticky_footer) {
|
if (this.sticky_footer) {
|
||||||
let resizeObs = new ResizeObserver(entries => {
|
let resizeObs = new ResizeObserver(entries => {
|
||||||
|
|
|
@ -49,7 +49,9 @@ export class SideBarComponent implements OnInit, AfterViewInit, OnDestroy, OnCha
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
this.toggle(true);
|
setTimeout(() => {
|
||||||
|
this.toggle(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
|
Loading…
Reference in New Issue