ngx-perfect-scrollbar show hide footer

问题描述 投票:0回答:1

我正在尝试根据滚动方式使页脚向内/向外滑动。到目前为止,我唯一需要做的就是用psYReachEnd显示页脚,但是当我向上滚动100px时,如何“告诉”页脚滑出呢?

public onReachEnd(): void {
this.zone.run(() => {
  this.status = true;
});
console.log('show footer');}




<perfect-scrollbar (psYReachEnd)="onReachEnd()"><div>content</div><div id="footer" class="container-fluid" [ngClass]="status ? 'show' : 'hide'">footer content</div></perfect-scrollbar>
angular scroll footer
1个回答
0
投票

最后弄清楚了。如果其他人对此感兴趣,那么是可行的解决方案(对我来说)

constructor(private zone: NgZone) {}

status = false;

@HostListener('scroll', ['$event'])
onScrollY(event) {
if (event.target.offsetHeight + event.target.scrollTop >= event.target.scrollHeight) {
  this.zone.run(() => {
    this.status = true;
  });
} else {
  this.zone.run(() => {
   this.status = false;
 });
}
}




<perfect-scrollbar (psScrollY)="onScrollY($event)">
   <div [ngClass]="status ? 'show' : 'hide'">content</div>
</perfect-scrollbar>

ps:如果还有其他Angular解决方案,请发布

© www.soinside.com 2019 - 2024. All rights reserved.