mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Add scroll to bottom btn in chat conversation
This commit is contained in:
@@ -50,6 +50,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
private scrollChangeCallback: () => void;
|
||||
currentPosition: any;
|
||||
startPosition: number;
|
||||
mesageItemDropdownOptions: boolean = false;
|
||||
scrollToBottomBtn = false;
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
@@ -122,6 +124,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
} catch(err) { }
|
||||
}
|
||||
|
||||
scrollToBottomClicked(): void {
|
||||
try {
|
||||
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
||||
//this.scrollingOnce = false;
|
||||
} catch(err) { }
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.scrollChangeCallback = () => this.onContentScrolled(event);
|
||||
window.addEventListener('scroll', this.scrollChangeCallback, true);
|
||||
@@ -130,17 +139,22 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
onContentScrolled(e) {
|
||||
this.startPosition = e.srcElement.scrollTop;
|
||||
let scroll = e.srcElement.scrollTop;
|
||||
let windowHeight = e.srcElement.scrollHeight;
|
||||
let containerHeight = windowHeight - 454.199951171875;
|
||||
|
||||
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);
|
||||
console.log(this.scrollingOnce); */
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
||||
Reference in New Issue
Block a user