This commit is contained in:
tiago.kayaya
2021-09-24 15:39:25 +01:00
parent 77cb5ad73b
commit 45197375ff
6 changed files with 107 additions and 11 deletions
@@ -74,6 +74,11 @@
</div>
</div>
</div>
<ion-fab horizontal="end" vertical="bottom" slot="fixed">
<ion-fab-button *ngIf="scrollToBottomBtn" (click)="scrollToBottomClicked()" color="light" size="small">
<ion-icon name="chevron-down"></ion-icon>
</ion-fab-button>
</ion-fab>
</ion-content>
+22 -3
View File
@@ -45,6 +45,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
private scrollChangeCallback: () => void;
currentPosition: any;
startPosition: number;
scrollToBottomBtn = false;
attendees: EventPerson[] = [];
constructor(
@@ -122,23 +123,41 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
} catch(err) { }
}
scrollToBottomClicked(): void {
try {
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
} catch(err) { }
}
ngAfterViewInit() {
this.scrollChangeCallback = () => this.onContentScrolled(event);
window.addEventListener('scroll', this.scrollChangeCallback, true);
}
onContentScrolled(e) {
onContentScrolled(e) {
this.startPosition = e.srcElement.scrollTop;
let scroll = e.srcElement.scrollTop;
let windowHeight = e.srcElement.scrollHeight;
let containerHeight = windowHeight - 596.59997558594;
console.log(this.startPosition);
console.log(windowHeight);
if (scroll > this.currentPosition) {
//this.showButton = false;
//alert('BOTTOM');
} else {
//this.showButton = true;
//alert('UP');
this.scrollingOnce = false;
}
if((containerHeight - 100) > scroll){
this.scrollToBottomBtn = true;
}
else{
this.scrollToBottomBtn = false;
}
this.currentPosition = scroll;
console.log(this.currentPosition);
}
ngOnDestroy() {