AJAX Control Toolkit Tutorial: AnimationExtender- Part Five

Animation is just the extender control which will add animation to the page. Animation can be played through a number of events attached to it like OnMouseOver, OnMouseOut, OnClick and OnLoad raised by the target control.

You can learn more in my previous parts here:

There are a number of useful animation effects like fading, resizing, movement and much more.

Initial Code for implementation of animation.

  1. <asp:Panel Direction="NotSet" ID="socialmediaicons" runat="server">  
  2.   
  3.     <asp:Image ID="imgflagpak" runat="server" ImageUrl="~/Images/Flag_Of_Pakistan-1969px.jpg" Width="500px" BorderColor="Black" BorderStyle="Dotted" BorderWidth="3px" />  
  4.   
  5. </asp:Panel>  
  6.   
  7. <div class="row">  
  8.   
  9.     <div id="ajaxcontroltoolkitplaceholder">  
  10.   
  11.         <ajaxToolkit:AnimationExtender ID="ae" runat="server" TargetControlID="socialmediaicons">  
  12.   
  13.             <Animations>  
  14.   
  15.                 <OnLoad>  
  16.   
  17.                     <Sequence>  
  18.   
  19.                         <Color Duration="3" StartValue="#FF3300" EndValue="#0033FF" Property="style" PropertyKey="color" />  
  20.   
  21.                         <OpacityAction AnimationTarget="imgAjax" Opacity="0.5" />  
  22.   
  23.                     </Sequence>  
  24.   
  25.                 </OnLoad>  
  26.   
  27.             </Animations>  
  28.   
  29.         </ajaxToolkit:AnimationExtender>  
  30.   
  31.     </div>   

Output

Now let’s discuss its properties

Properties

OnLoad

It can call animation as soon as the page load event fires.

  1. <asp:Panel Direction="NotSet" ID="socialmediaicons" runat="server">  
  2.   
  3.     <asp:Image ID="imgflagpak" runat="server" ImageUrl="~/Images/Flag_Of_Pakistan-1969px.jpg" Width="500px" BorderColor="Black" BorderStyle="Dotted" BorderWidth="3px" />  
  4.   
  5. </asp:Panel>  
  6.   
  7. <div class="row">  
  8.   
  9.     <div id="ajaxcontroltoolkitplaceholder">  
  10.   
  11.         <ajaxToolkit:AnimationExtender ID="ae" runat="server" TargetControlID="socialmediaicons">  
  12.   
  13.             <Animations>  
  14.   
  15.                 <OnLoad>  
  16.   
  17.                     <Sequence>  
  18.   
  19.                         <Color Duration="3" StartValue="#FF3300" EndValue="#0033FF" Property="style" PropertyKey="color" />  
  20.   
  21.                         <OpacityAction AnimationTarget="imgAjax" Opacity="0.5" />  
  22.   
  23.                     </Sequence>  
  24.   
  25.                 </OnLoad>  
  26.   
  27.             </Animations>  
  28.   
  29.         </ajaxToolkit:AnimationExtender>  
  30.   
  31.     </div>  

 

Inside the Animations section we have declared OnLoad Server Property to initialize it on page load.

As you can see in the code we have used Sequence tag; also where we have declared multiple animation effects firstly it take three seconds and then it changes its opacity to 0.5 percent.

Check it out in action,



OnClick

The animation starts playing on button, image or any clickable thing.

  1. <OnClick>  
  2.   
  3.     <Sequence>  
  4.   
  5.         <Resize Width="2000" Height="150" />  
  6.   
  7.         <FadeIn Duration="2" Fps="20" />  
  8.   
  9.     </Sequence>  
  10.   
  11. </OnClick>   

Code first resizes the picture and then fades in animation after a two second duration.

Output



OnMouseOver

Animation is played when mouse moves over the target control.

  1. <OnMouseOver>  
  2.   
  3.     <Sequence>  
  4.   
  5.         <Parallel AnimationTarget="imgflagpak" Duration="1">  
  6.   
  7.             <FadeIn Duration="2" Fps="20" />  
  8.   
  9.         </Parallel>  
  10.   
  11.     </Sequence>  
  12.   
  13. </OnMouseOver>   

See this in action,

OnMouseOut

Animation is played when mouse moves out of the target control.

  1. <OnMouseOut>  
  2.   
  3.     <Sequence>  
  4.   
  5.         <Parallel AnimationTarget="imgflagpak" Duration="1">  
  6.   
  7.             <FadeIn Duration="2" Fps="20" />  
  8.   
  9.             <Scale Duration="1" Fps="20" ScaleFactor="4.0" Center="true" />  
  10.   
  11.         </Parallel>  
  12.   
  13.     </Sequence>  
  14.   
  15. </OnMouseOut>  

 

Output

 
OnHoverOver

Generic animation similar to OnMouseOver except it will stop the OnHoverOut animation before it plays

  1. <OnHoverOver>  
  2.   
  3.     <Sequence>  
  4.   
  5.         <FadeOut Duration="2" MinimumOpacity="0.5" MaximumOpacity="1" />  
  6.   
  7.         <ScriptAction Script="alert('on hover over');" />  
  8.   
  9.     </Sequence>  
  10.   
  11. </OnHoverOver>  

 

Output
 

OnHoverOut

Generic animation similar to OnMouseOut except it will stop the OnHoverOver animation before it plays

  1. <OnHoverOut>  
  2.   
  3.     <Sequence>  
  4.   
  5.         <FadeOut Duration="2" MinimumOpacity="0.5" MaximumOpacity="1" />  
  6.   
  7.         <ScriptAction Script="alert('on hover out');" />  
  8.   
  9.     </Sequence>  
  10.   
  11. </OnHoverOut>  

 

Output



Similar Articles