当底部到达 android 和 IOS 时检测 VertScrollBox

VertScrollBox Detect when bottom reached android and IOS

我在 VertScrollBox1 上有 GridLayout1。垂直滚动框滚动网格布局的内容。我需要检测垂直滚动框何时到达底部,以便将更多内容加载到网格布局。 每当再次到达底部时再做一次。

我怎样才能做到这一点?

使用OnViewportPositionChange()VertScrollBox1。然后一些简单的算术告诉你什么时候在底部:

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;

由于我们比较的值是浮点数,所以使用Math.CompareValue()进行比较。

或者function SameValue(),也在Math单元