Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How do you implement animation functionality ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 318
    Comment on it

    Hello Readers,

    Jquery implement the animation functionality using jquery.animate() methods.Animate method performs animation effects on CSS properties and it's effect be on custom animation and the CSS properties should be numeric.Using this properties animate() method changes the state from one state to another and CSS property value changed gradually to create the animation effets.

    Syntax :

    (selector).animate({styles},speed,easing,callback)
    

    Paramter:

    styles: this parameter specifies one or more CSS properties to animate.

    speed or (duration): It's a optional parameter which specifies the speed of the animation.It's default value is 400 ms.

    speed parameter possible values are:

    "milliseconds"
    "slow"
    "fast"
    

    easing: It's also a optional parameter which specifies the speed of the element in different points of the animation. It's default value is "swing".

    easing parameter possible values are :

    "swing" - swing moves slower at the beginning or at the end, but faster in the middle. "linear" - linear moves in a constant speed.

    callback: callback also a optional parameter.This function to be executed after completes the animation.

    Below is the Code Example of animation method:

    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("#btn1").click(function(){
            $("#box").animate({height: "300px"});
        });
        $("#btn2").click(function(){
            $("#box").animate({height: "100px"});
        });
    });
    </script>
    </head>
    <body>
    
    <button id="btn1">Animate height</button>
    <button id="btn2">Reset height</button>
    
    <div id="box" style="background:#98bf21;height:100px;width:100px;margin:6px;"></div>
    
    </body>
    </html>
    

    In the above, code example we use the animate() method to animate the height 300px on click of Animate height button and then reset the height 100px after click on other reset height button.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: