複数のアニメーションを順番に実行する (C#)

作成者: Christian Wenz

PDF のダウンロード

ASP.NET AJAX Control Toolkit のアニメーション コントロールは、単なるコントロールではなく、コントロールにアニメーションを追加するためのフレームワーク全体です。 これにより、複数のアニメーションを順番に実行できます。

ASP.NET AJAX Control Toolkit のアニメーション コントロールは、単なるコントロールではなく、コントロールにアニメーションを追加するためのフレームワーク全体です。 これにより、複数のアニメーションを順番に実行できます。

手順

まず、ページに ScriptManager を含めます。これにより、ASP.NET AJAX ライブラリが読み込まれ、Control Toolkit を使用できるようになります。

<asp:ScriptManager ID="asm" runat="server" />

アニメーションは、次のようなテキストのパネルに適用されます。

<asp:Panel ID="panelShadow" runat="server" CssClass="panelClass">
 ASP.NET AJAX is a free framework for quickly creating a new generation of more 
 efficient, more interactive and highly-personalized Web experiences that work 
 across all the most popular browsers.<br />
 ASP.NET AJAX is a free framework for quickly creating a new generation of more 
 efficient, more interactive and highly-personalized Web experiences that work 
 across all the most popular browsers.<br />
 ASP.NET AJAX is a free framework for quickly creating a new generation of more 
 efficient, more interactive and highly-personalized Web experiences that work 
 across all the most popular browsers.<br />
</asp:Panel>

パネルに関連付けられている CSS クラスで、適切な背景色を定義し、パネルの固定幅も設定します。

<style type="text/css">
 .panelClass {background-color: lime; width: 300px;}
</style>

次に AnimationExtender をページに追加し、IDTargetControlID 属性、および必須の runat="server": を追加します。

<ajaxToolkit:AnimationExtender ID="ae" runat="server" TargetControlID="Panel1">

<Animations> ノード内で、ページが完全に読み込まれたらアニメーションを実行するように <OnLoad> を使用します。 一般に、 <OnLoad> は 1 つのアニメーションのみを受け入れます。 アニメーション フレームワークを使用すると、<Sequence> 要素を使用して複数のアニメーションを 1 つに結合できます。 <Sequence> 内のすべてのアニメーションが順番に実行されます。 以下は、AnimationExtender コントロールで使用できるマークアップです。最初にパネルの幅を広げ、次にその高さを小さくします。

<ajaxToolkit:AnimationExtender ID="ae" runat="server" TargetControlID="Panel1">
 <Animations>
 <OnLoad>
 <Sequence>
 <Resize Width="1000" Unit="px" />
 <Resize Height="150" Unit="px" />
 </Sequence>
 </OnLoad>
 </Animations>
</ajaxToolkit:AnimationExtender>

このスクリプトを実行すると、パネルは、最初に幅が広くなってから、次に小さくなります。

First the width is increased

最初に幅が広くなります (クリックするとフルサイズの画像が表示されます)

Then the height is decreased

次に、高さが小さくなります (クリックするとフルサイズの画像が表示されます)