Delphi FMX TAnimator. How to animate a TPointF


I have a TScrollbox on my form. Placed onto the Scrollbox is a TLayout that is wider and taller than the device viewport so the horiz and vert scrollbars show and the user can manually move the layout.

I also have a gesture setup so that the user can longpress the Scrollbox and get the layout back to origin (0,0).

procedure TfrmMain.ScrollBox1Gesture(Sender: TObject;
const EventInfo: TGestureEventInfo; var Handled: Boolean);
if EventInfo.GestureID = System.UITypes.igiLongTap then
ScrollBox1.ViewportPosition := PointF(0, 0);

Now this works great, but as it happens rather quickly. I thought perhaps I could use:

TAnimator.AnimateFloat(Scrollbox1, ‘ScrollBox1.ViewportPosition.X’, 0, 0.3);

to make the movement from current position back to 0 a bit more gentle, but of course, that’s never going to work because you can’t assign a value to a PointF.X or PointF.Y directly (and therefore neither can the animator).

So how can it be done?

Comments are closed.