VertScrollBox Detect when bottom reached android and IOS
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.
GridLayout1
VertScrollBox1
How can I achieve this?
1 Answer
1
Use the OnViewportPositionChange()
of the VertScrollBox1
. Then some simple arithmetics tell you when you are at the bottom:
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;
Since the values we compare are floats, use Math.CompareValue()
for comparison.
Math.CompareValue()
Alternatively function SameValue()
, also in the Math
unit
function SameValue()
Math
@loki Yes, thanks, you are right. Changed.
– Tom Brunberg
Jul 1 at 9:11
i am very appreciated
– Someone
Jul 1 at 12:44
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I guess you mean if comparevalue(NewViewportPosition.Y, GridLayout1.Height - VertScrollBox1.Height) ;)
– loki
Jul 1 at 8:11