Animate () Usage

Source: Internet
Author: User

Animate (params, speed, easing, callback) is a function used to create custom animations.

The key to this function is to specify the animation form and result style attribute object. Each attribute in this object represents a changeable style attribute (such as "height", "top", or "opacity "). The value of each attribute indicates the animation ends when the style attribute is reached. If it is a value, the style property will gradually change from the current value to the specified value. If a string value such as "hide", "show", or "toggle" is used, the default animation format is called for this attribute.

Params (Hash): a set of style attributes and their values that are used as animation attributes and final values.

Speed (String | Number): (optional) a String ("slow", "normal", or "fast") with one of the three predefined speeds, or represents the maximum animation duration.

Second value (for example, 1000)

Easing (String): (optional) Name of the erased effect to be used (supported by the plug-in ).

Callback (Function): (optional) Function executed when the animation is completed

 

 

Opacity: used to set the transparency of an image.

Code
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head id = "head1" runat = "server">
<Title> </title>
<SCRIPT type = "text/JavaScript" src = "JS/Alice. js"> </SCRIPT>

<Style type = "text/CSS">
# Box {
Background: green;
Height: 30px;
Width: 30px;
Position: relative;
Top: 20;
Left: 100%;
}

</Style>
<Script>

$ (Document). ready (function (){
$ ("Div"). hover (function (){
$ ("# Box ")
. Animate ({opacity: "1", left: "400", top: "500", height: "50", width: "50"}, 1200)
. Animate ({opacity: "1", top: "20", height: "70", width: "70" }," 1000000 ")
. Animate ({opacity: "1", left: "20", top: "400", height: "100", width: "100"}, "slow ")
. Animate ({top: "0"}, "fast ")
. SlideUp ()
. SlideDown ("slow ")
Return false;
});

});

</Script>


</Head>
<Body>
<Div id = "box">
</Div>

<Body>
</Html>

Hover (): it is equivalent to a hover event, as mentioned earlier.

SlideUp (speed, callback): dynamically hides all matching elements by changing the height (decreasing upwards). After hiding, a callback function is triggered. This animation only adjusts the height of the element, so that the matching element can be hidden by sliding. (Parameters are not required in slideUp)

Speed (string | Number): (optional) a string ("slow", "normal", or "fast") with one of the three predefined speeds, or the animation duration in milliseconds.

Numeric value (for example, 1000)

Callback (function): (optional) function executed when the animation is completed

Example: 1. $ ("p"). slideup ("slow ");

2. $ ("p"). slideup ("slow", function () {alert ("animation done .");});

Slidedown (speed, callback): it is the same as slideup () usage. The only difference is that slidedown () increases down. Here we omit ...........

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.