简体   繁体   中英

VertScrollBox Detect when bottom reached android and IOS

I have GridLayout1 on a VertScrollBox1 . The vertical scroll box scrolls through the content of the grid layout. I need to detect when the Vertical scroll box reach the bottom so I get to load more content to the grid layout. And do it again whenever bottom is reached again.

How can I achieve this?

Use the OnViewportPositionChange() of the VertScrollBox1 . Then some simple arithmetics tell you when you are at the bottom:

uses Math, ...;
// ...

procedure TForm1.VertScrollBox1ViewportPositionChange(Sender: TObject;
  const OldViewportPosition, NewViewportPosition: TPointF;
  const ContentSizeChanged: Boolean);
begin
  if CompareValue(NewViewportPosition.Y, GridLayout1.Height - VertScrollBox1.Height) = EqualsValue then
    Memo1.Lines.Add('At bottom, time to grow and load more content to the GridLayout');
end;

Since the values we compare are floats, use Math.CompareValue() for comparison.

Alternatively function SameValue() , also in the Math unit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM