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>
|
</div>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
export class PageContentComponent implements OnInit, OnDestroy{
|
export class PageContentComponent implements OnInit{
|
||||||
private current;
|
|
||||||
public offset: string;
|
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() {
|
ngOnInit() {
|
||||||
if(typeof window !== "undefined") {
|
this.offset = getComputedStyle(document.documentElement).getPropertyValue('--structure-header-height');
|
||||||
this.current = window.pageYOffset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,7 +266,7 @@
|
||||||
<img *ngIf="(mobile && header.logoSmallUrl) || (!mobile && header.logoUrl)"
|
<img *ngIf="(mobile && header.logoSmallUrl) || (!mobile && header.logoUrl)"
|
||||||
[src]="!mobile?header.logoUrl:header.logoSmallUrl"
|
[src]="!mobile?header.logoUrl:header.logoSmallUrl"
|
||||||
[alt]="header.title"
|
[alt]="header.title"
|
||||||
class="uk-responsive-height">
|
class="uk-width-1-1">
|
||||||
<ng-container *ngIf="(mobile && !header.logoSmallUrl) || (!mobile && !header.logoUrl)">
|
<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">
|
<div class="multi-line-ellipsis lines-2" [style.max-width]="(!mobile)?'25vw':null" [title]="header.title">
|
||||||
<p class="uk-margin-remove">{{header.title}}</p>
|
<p class="uk-margin-remove">{{header.title}}</p>
|
||||||
|
@ -278,7 +278,7 @@
|
||||||
<img *ngIf="(mobile && header.logoSmallUrl) || (!mobile && header.logoUrl)"
|
<img *ngIf="(mobile && header.logoSmallUrl) || (!mobile && header.logoUrl)"
|
||||||
[src]="!mobile?header.logoUrl:header.logoSmallUrl"
|
[src]="!mobile?header.logoUrl:header.logoSmallUrl"
|
||||||
[alt]="header.title"
|
[alt]="header.title"
|
||||||
class="uk-responsive-height">
|
class="uk-width-1-1">
|
||||||
<ng-container *ngIf="(mobile && !header.logoSmallUrl) || (!mobile && !header.logoUrl)">
|
<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">
|
<div class="multi-line-ellipsis lines-2" [style.max-width]="(!mobile)?'25vw':null" [title]="header.title">
|
||||||
<p class="uk-margin-remove">{{header.title}}</p>
|
<p class="uk-margin-remove">{{header.title}}</p>
|
||||||
|
|
Loading…
Reference in New Issue