如何知道PrimeNG滚动面板何时位于底部?

时间:2019-02-04 08:39:33

标签: angular primeng

我正在使用PrimeNG ScrollPanel显示一些文本,我希望用户在启用按钮以继续操作之前滚动到底部。

我看了看文档,但是找不到找到当前滚动位置是什么和/或滚动时有事件的方法。有办法吗?

谢谢

2 个答案:

答案 0 :(得分:0)

您可以使用scrollTop方法。例子;

<p-scrollPanel #sc [style]="{width: '100%', height: '200px'}">
            <div style="padding:1em;line-height:1.5">
                The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding. His beloved
                son Michael has just come home from the war, but does not intend to become part of his father's business. Through
                Michael's life the nature of the family business becomes clear. The business of the family is just like the head
                of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands
                against the good of the family.
                The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding. His beloved
                son Michael has just come home from the war, but does not intend to become part of his father's business. Through Michael's
                life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind
                and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the
                family.
            </div>
        </p-scrollPanel>
        <button (click)="sc.scrollTop(500)">Scroll bottom</button>

答案 1 :(得分:0)

您可以改用virtualScroller,它没有滚动条位置检测功能,但是它有一个名为“懒惰滚动”的属性,您可以在滚动条到达终点时执行操作。