FMX.Forms.TCustomPopupForm.AniPosition

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property AniPosition: Single read FAniPosition;

C++

__property float AniPosition = {read=FAniPosition};

Properties

Type Visibility Source Unit Parent
property public
FMX.Forms.pas
FMX.Forms.hpp
FMX.Forms TCustomPopupForm

Description

Read-only property returning values between 0 and 1. You can use AniPosition in an OnAniTimer event handler.

The AniPosition value changes during AniDuration time of a custom animation execution from 0 to 1 (during opening of the current pop-up form) and from 1 to 0 (during closing) respectively.

AniPosition might be used as a parameter in intermediate values of animated properties in an OnAniTimer event handler. For example, you can use AniPosition to calculate an intermediate position or intermediate opacity during custom animation. Where AniPosition = 0 corresponds to a starting moment and AniPosition = 1 to a termination of opening animation.

For example, in the sample below the form Width (as a component of the form Size) changes from 0 (when AniPosition = 0) to 200 (when AniPosition = 1) during appearing of the pop-up form and vice versa on the form closing:

...
procedure TForm1.AniTimerProc(Sender: TObject);
begin
  if Sender is TCustomPopupForm then
  begin
//    You can use AniPosition whether to define Opacity or Size
//    TCustomPopupForm(Sender).ContentControl.Opacity := TCustomPopupForm(Sender).AniPosition;
    TCustomPopupForm(Sender).Size := TSize.Create(Round(200 * TCustomPopupForm(Sender).AniPosition), 100);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  R: TRectangle;
begin
  R := TRectangle.Create(Self);
  F := TCustomPopupForm.Create(Self);
  F.AniDuration := 0.5;
  F.ContentControl := R;
  F.OnAniTimer := AniTimerProc;
  F.PlacementTarget := Button1;
  F.Show;
end;
...

Commented line shows how to use AniPosition to animate a form transparency.

See also discussion in TPopup.OnAniTimer.

See Also