Change page-content to be sticky on scroll up
This commit is contained in:
parent
f5b4677b63
commit
d7598eb350
|
@ -15,31 +15,10 @@ import {ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit} from "@an
|
|||
</div>
|
||||
`
|
||||
})
|
||||
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 {
|
||||
ngOnInit() {
|
||||
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() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@
|
|||
<img *ngIf="(mobile && header.logoSmallUrl) || (!mobile && header.logoUrl)"
|
||||
[src]="!mobile?header.logoUrl:header.logoSmallUrl"
|
||||
[alt]="header.title"
|
||||
class="uk-responsive-height">
|
||||
class="uk-width-1-1">
|
||||
<ng-container *ngIf="(mobile && !header.logoSmallUrl) || (!mobile && !header.logoUrl)">
|
||||
<div class="multi-line-ellipsis lines-2" [style.max-width]="(!mobile)?'25vw':null" [title]="header.title">
|
||||
<p class="uk-margin-remove">{{header.title}}</p>
|
||||
|
@ -278,7 +278,7 @@
|
|||
<img *ngIf="(mobile && header.logoSmallUrl) || (!mobile && header.logoUrl)"
|
||||
[src]="!mobile?header.logoUrl:header.logoSmallUrl"
|
||||
[alt]="header.title"
|
||||
class="uk-responsive-height">
|
||||
class="uk-width-1-1">
|
||||
<ng-container *ngIf="(mobile && !header.logoSmallUrl) || (!mobile && !header.logoUrl)">
|
||||
<div class="multi-line-ellipsis lines-2" [style.max-width]="(!mobile)?'25vw':null" [title]="header.title">
|
||||
<p class="uk-margin-remove">{{header.title}}</p>
|
||||
|
|
Loading…
Reference in New Issue