ラベル animation の投稿を表示しています。 すべての投稿を表示
ラベル animation の投稿を表示しています。 すべての投稿を表示

2012年3月28日水曜日

Re-Setting an Object to its original position using Animation Extender

Hi

I have been working on a nice ajax menu using the Animation Extender. Basically, i have a series of GIF's. When the mouse hovers over a gif, the gif moves 6px to the right. When the mouse hovers out, the gif moves 6px to the left.

Everything works well, if you let the whole animation run through. But if you where to move your mouse off and on the gif a few times in a short period, the gif would actually lose its original position and end up either further left or further right to where it should.

I spose what I am trying to get at is, is it possible to reset an objects original position?

Here is a sample of my extender:

<cc1:AnimationExtender ID="AnimationExtender3" runat="server" TargetControlID="btnPro">
<Animations>
<OnHoverOver>
<Move duration=".03" fps="50" horizontal="6" unit="px"/>
</OnHoverOver>
<OnHoverOut>
<Move duration=".03" fps="50" horizontal="-6" unit="px"/>
</OnHoverOut>
</Animations>
</cc1:AnimationExtender>

Thanks for your help in advance.

Hugh

Would any one have an easier way of doing this?

Thanks

Hugh


HI ,

try this link :

Scripting Animations from the Ms Ajax AnimationExtender

Hope this heps


Thanks for the link.

This would be perfect for wat i am trying to do. Problem is i cant seem to get it to work on a hover over event, instead of a click event.

Any ideas?

Thanks

Hugh

Resize animation with RoundedCorners

I have

<div id="div2" runat="server" style='width: 300px; height: 200px; background-color: teal; position: absolute;'>

and

<cc2:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server">
<cc2:RoundedCornersProperties Radius="10" TargetControlID="div2"></cc2:RoundedCornersProperties>
</cc2:RoundedCornersExtender>

and

<cc2:AnimationProperties TargetControlID="div1">
<Animations><OnHoverOver>
<Resize AnimationTarget="div2" Width="500" Height="400" />
</OnHoverOver></Animations>
</cc2:AnimationProperties>

and when i hover over div1... only width changes. A bug?

Hi MarekG,

This is a consequence of the way that RoundedCorners works. It will wrap your target control in another div and set the height of the new div to be the same. If the inner height changes it won't propogate to the containing wrapper (i.e. you're resizing the wrapped control, but it's overflow is hidden by its wrapper so you see nothing happen).

Right now there isn't a way to work around this - but I hope to make some modifications to the Animation framework on the next release that will allow you to side step the issue.

Thanks,
Ted

Resizing a panel using Animation Extender

Hi Everyone,

I have 3 rows of images on my form and each row has 3 images as well. I want to have a effect so that when the user hovers on a row than that row expands itself and the rest of the rows remain the same size.

To do this I used 3 panels and in each panel I inseted a table so as to accomodate the 3 images.

Then to add the Hover effect I used the Animation extender control. The code that I used is given below.

<cc1:AnimationExtenderID="AnimationExtender1"runat="server"TargetControlID="Panel1">

<Animations>

<OnHoverOver>

<ParallelDuration=".1"fps="50">

<ResizeWidth="250"Height="260" />

</Parallel>

</OnHoverOver>

</Animations>

</cc1:AnimationExtender>

However this doesn't seem to work. Any idea about why this is happening. It seems to me that I am making a really basic mistake but I have been trying to make this work for quite some days with no success.

If anyone has any idea what the problem is here please let me know.

Thanks

Hi,

I created a sample that works fine according to your description, please try it:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <table> <tr> <td> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Add.gif" Height="50" Width="50"/> <ajaxtoolkit:AnimationExtender ID="AnimationExtender1" runat="server" TargetControlID="Image1"> <Animations> <OnHoverOver> <Parallel Duration=".1" fps="50"> <Resize Width="250" Height="250" /> </Parallel> </OnHoverOver> <OnHoverOut> <Parallel Duration=".1" fps="50"> <Resize Width="50" Height="50" /> </Parallel> </OnHoverOut> </Animations> </ajaxtoolkit:AnimationExtender> </td> <td> <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/edit.gif" Height="50" Width="50"/> <ajaxtoolkit:AnimationExtender ID="AnimationExtender2" runat="server" TargetControlID="Image2"> <Animations> <OnHoverOver> <Parallel Duration=".1" fps="50"> <Resize Width="250" Height="250" /> </Parallel> </OnHoverOver> <OnHoverOut> <Parallel Duration=".1" fps="50"> <Resize Width="50" Height="50" /> </Parallel> </OnHoverOut> </Animations> </ajaxtoolkit:AnimationExtender> </td> <td> <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/delete.gif" Height="50" Width="50"/> <ajaxtoolkit:AnimationExtender ID="AnimationExtender3" runat="server" TargetControlID="Image3"> <Animations> <OnHoverOver> <Parallel Duration=".1" fps="50"> <Resize Width="250" Height="250" /> </Parallel> </OnHoverOver> <OnHoverOut> <Parallel Duration=".1" fps="50"> <Resize Width="50" Height="50" /> </Parallel> </OnHoverOut> </Animations> </ajaxtoolkit:AnimationExtender> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> </div> </form></body></html>

Thanks Raymond that surely helps....

However I have another problem and it will be great if you can have a look at that also....

http://forums.asp.net/p/1168745/1950736.aspx#1950736

Thanks in advance

vishy

2012年3月24日土曜日

Reuse AnimationExtenders

Hello!

I have a website where I want to put a kind of tooltips using animation extender. In each page (aspx file) there should be 4 tooltips, one in each textbox that the user has to fill.

They're gonna have the same estructure, i mean, one little button with the "?" sign, and when u click on it, the window with the info appears. For the 4 buttons, the animation code is the same (is the example of animation that appears in the AJAX Toolkit animation: resize and fade in a div with the information). The only thing it'll change is the target between the different animation extender. Is there any possibility to write only 2 animation extender(one to open the help and other to close it) for all of them, instead of one animation extender pair for each one?

In case is not possible, having so many extenders, can affect the speed of serving pages to the user?

Thanks a lot.

Oscar

yes

Hi,

thx for answering, but, "yes"? which question of them are u answering?


if possible to reuse the animation extender for several buttons? how please?

is gonna to slow the website if I put one for each button?


thx


Hi Oscar,

You can reuse an Animation Extender by providing its markup and changing the TargetControl before running it .

You can take a look at my post which talks about various ways to trigger the animations and how to use them to have a common schema for animations on a page.

http://blogs.msdn.com/phaniraj/archive/2007/04/13/animations-how-many-ways-do-i-call-thee.aspx

Hope this helps !!


Hi,

Firt of all, thx for answering (I've seen in different forums that u're quite active!). I am quite new using AJAX, so, is being difficult to me solving this problem. In ur post I've seen a method that can be easier for me. Instead of using the XML to define the actions, I'm gonna use a script that takes as params the targets of the actions.

So, my main problem now is to "translate" the XML I have to a function. I am having problems "translating" the <Parallel> tag. I hope u can help me with this:

<Parallel AnimationTarget="flyout" Duration=".3" Fps="25">
<Move Horizontal="150" Vertical="-50" />
<Resize Height="260" Width="280" />
<Color AnimationTarget="flyout" PropertyKey="backgroundColor"
StartValue="#AAAAAA" EndValue="#FFFFFF" />
</Parallel>

And this is what I've done:

function callStaticMethods(var_flyout){

var flyout = document.getElementById(var_flyout);

var par = new AjaxControlToolkit.Animation.ParallelAnimation();
par.add(new AjaxControlToolkit.Animation.ColorAnimation(flyout, 0.5, 25, 'style', 'backgroundColor', '#FFFFFF', '#AAAAAA'));
par.add(new AjaxControlToolkit.Animation.MoveAnimation(flyout, 0.3, 25, 500, 500, true, "px"));
par.add(new AjaxControlToolkit.Animation.ResizeAnimation(null, null, null, 260, 280, "px"));
par.play;

}

but nothing happens then.Do u know where is the problem??

Thx a lot!


Hi Oscar,
You got 90% of it rightSmile!!
The part that you missed is that when you use the script method of the animation
framework , you need to specify the targetControlId in the parent.

Please review the script method.

function callStaticMethods(var_flyout){

var flyout = $get(var_flyout);
var par = new AjaxControlToolkit.Animation.ParallelAnimation(flyOut, 0.3 , 25, null);
par.add( new AjaxControlToolkit.Animation.MoveAnimation(null, null, null, 150, -50,false, "px") );
par.add( new AjaxControlToolkit.Animation.ResizeAnimation(null, null, null, 280, 260, "px"));
par.add (new AjaxControlToolkit.Animation.ColorAnimation(null, null, null, "style" , "backgroundColor", "#AAAAAA", "#FFFFFF")
);
par.play()

}

On the other hand , if you have the Markup for the Animation on the page,
Conside the method "c) Selectively playing the Animation Already defined in Markup for an AnimationExtender on the Page."
described in my blog post for triggering the animation by changing the appropriate properties.

1) Assign a BehaviorId for your Animation Extender to be
<ajaxToolkit:AnimationExtender AnimationTargetScript="getCurrentElement()" BehaviorID ="parBehavior" ......>
<OnClick>
//ANimations Here.
</OnClick>
</ajaxToolkit:AnimationExtender
2)
//A Global Variable to Hold the Current Element to be animated.
var currentElement = ""
function getCurrentElement() {
return currentElement;
}
function callStaticMethods(var_flyout) {
currentElement = var_flyout;
//Get a handle to the Animation Behavior
var behaveYourself = $find("parBehavior");
//Get the Animation to be played onClick of the TargetControl
var onClickAnimation = behaveYourself.get_OnClickBehavior();
behaveYourself.play();
}

Hope this helps.
If this resolves your issue , please mark my reply as the answer.


Hi man!

First of all say that I'm feeling quiet stupid (well, i think "novice" is the word hehe) because you're giving me it so detailed and I still can′t make it works:

Problems:


a)The AnimationTargetScript in the AnimationExtender tag launchs an error and doesn′t allow me to execute (it says that is not a valid tag).

b) In ur example, I can′t see from where do u call the callStaticMethods function.

May be is useful if I explain a bit more what I want to do. In my animation extender there are 4 targets that should change by code depending wich button I play. Here is the code:

<asp:Button ID="btnInfo" runat="server" OnClientClick="return false;" Text="Click Here"/><!-- "Wire frame" div used to transition from the button to the info panel --> <div id="flyout" class="wireFrame"></div><!-- Info panel to be displayed as a flyout when the button is clicked --> <div id="info" style="display: none; width: 250px; z-index: 2; opacity: 0; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0); font-size: 12px; border: solid 1px #CCCCCC; background-color: #FFFFFF; padding: 5px;"> <div id="btnCloseParent" style="float: right; opacity: 100; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);"> <asp:LinkButton id="btnClose" runat="server" OnClientClick="return false;" Text="X" ToolTip="Close" Style="background-color: #666666; color: #FFFFFF; text-align: center; font-weight: bold; text-decoration: none; border: outset thin #FFFFFF; padding: 5px;" /> </div> Once you get the general idea of the animation's markup, you'll want to play a bit. All of the animations are created from simple, reusable building blocks that you can compose together. Before long you'll be creating dazzling visuals. By grouping steps together and specifying them to be run either in sequence or in parallel, you'll achieve almost anything you can imagine, without writing a single line of code! </div> <script type="text/javascript" language="javascript"> // Move an element directly on top of another element (and optionally // make it the same size) function Cover(bottom, top, ignoreSize) { var location = Sys.UI.DomElement.getLocation(bottom); top.style.position = 'absolute'; top.style.top = location.y + 'px'; top.style.left = location.x + 'px'; if (!ignoreSize) { top.style.height = bottom.offsetHeight + 'px'; top.style.width = bottom.offsetWidth + 'px'; } } </script> <ajaxToolkit:AnimationExtender id="OpenAnimation" runat="server" TargetControlID="btnInfo"> <Animations> <OnClick> <Sequence> <%-- Disable the button so it can't be clicked again --%> <EnableAction Enabled="false" /> <%-- Position the wire frame and show it --%> <ScriptAction Script="Cover($get('btnInfo'), $get('flyout'));" /> <StyleAction AnimationTarget="flyout" Attribute="display" Value="block"/> <%-- Move the wire frame from the button's bounds to the info panel's bounds --%> <Parallel AnimationTarget="flyout" Duration=".3" Fps="25"> <Move Horizontal="150" Vertical="-50" /> <Resize Width="260" Height="280" /> <Color PropertyKey="backgroundColor" StartValue="#AAAAAA" EndValue="#FFFFFF" /> </Parallel> <%-- Move the panel on top of the wire frame, fade it in, and hide the frame --%> <ScriptAction Script="Cover($get('flyout'), $get('info'), true);" /> <StyleAction AnimationTarget="info" Attribute="display" Value="block"/> <FadeIn AnimationTarget="info" Duration=".2"/> <StyleAction AnimationTarget="flyout" Attribute="display" Value="none"/> </Sequence> </OnClick> </Animations> </ajaxToolkit:AnimationExtender> <ajaxToolkit:AnimationExtender id="CloseAnimation" runat="server" TargetControlID="btnClose"> <Animations> <OnClick> <Sequence AnimationTarget="info"> <%-- Shrink the panel out of view --%> <StyleAction Attribute="overflow" Value="hidden"/> <Parallel Duration=".3" Fps="15"> <Scale ScaleFactor="0.05" Center="true" ScaleFont="true" FontUnit="px" /> <FadeOut /> </Parallel> <%-- Reset the target --%> <StyleAction Attribute="display" Value="none"/> <StyleAction Attribute="width" Value="250px"/> <StyleAction Attribute="height" Value=""/> <StyleAction Attribute="fontSize" Value="12px"/> <%-- Enable the button --%> <EnableAction AnimationTarget="btnInfo" Enabled="true" /> </Sequence> </OnClick> </Animations> </ajaxToolkit:AnimationExtender>
This example work perfectly. The problem is that I'm gonna have 4 groups of the structure "flyout", "info", "btnOpen", "btnClose".

Man, thx a lot for ur help. I'd like to know a bit more and for sure it'd have been enough with ur blog example.

Anyway, I keep on trying.


Rewiring Animation in the client side

I have a case where I have button A and button B that trigger four animations each. Can I in the client side rewire the animations so that all of them are triggered by button B? Or any other similar combination. I am trying to change the _onClickHandler references, but for a reason that I haven't figured out, it is not working. Let me know if any of you have done a similar thing.

Thanks

Hi ,

I have the perfect link for youSmile.

Check out this post which talks about how to use the AnimationExtender from the Client-Side

http://blogs.msdn.com/phaniraj/archive/2007/04/13/animations-how-many-ways-do-i-call-thee.aspx

Hope this helps


Yeah I saw that article, but that wasn't really my problem. Basically what I ended up doing is something along the lines of:

// get the animation that will be rehooked to another button
var anim = $find('animBehaviorID');

$addHandler($get('newbutton'), 'click', anim._onClickHandler);