Skip to main content

How to add Jquery easing effects | Jquery tutorial


Lets start with the a little introduction, easing refers to the acceleration and declaration that occurs during the course of an animation to give it a more responsive and natural feel. There are two types of easing methods that the core Jquery library supports, which are Linear and Swing lets us see how to implement this easing methods, but before that lets see a brief description on linear and swing easing methods.

Linear easing:
Linear easing method accelerates and deacclereates at a constant rate which makes it look fairly boring but it is good to know the linear easing might comin handy.
Linear Easing
Linear Easing


Swing easing:
Swing easing method starts off slowly before gaining speed and slows down again towards the end of the animation , which makes it look more natural compared to Linear easing



Swing easing
Swing easing

           Download Demo


<! DOCTYPE HTML>
</head>
<script type="text/javascript" src="jquery-1.7.2.min.js">
</script>
<script type="text/javascript" src="easing.js"></script>

<style>
div{ margin-left:5%; border:1px solid #999; border-radius:5px; width:350px; padding:6px; position: absolute; }
#al{ margin-top:0%; margin-left:50%;}
p{ height:150px; overflow:hidden;}
#anim{ position:absolute; margin-top:18%; margin-left:42%;}
#swing{ position:absolute; margin-top:22%; margin-left:42%;}


</style>
</head>
<body>
<div>
<p> type some text here </p>
</div>
<div id="al">
<p> type some text here </p>
</div>

<input name="animate" type="button" value="Linear" id="anim">
<input name="animate" type="button" value="Swing" id="swing">

<script type="text/javascript">
$('#anim').toggle(function() {
$('p').animate({'height':'+=150px'}, 2000, 'linear');
}, function() {
$('p').animate({'height':'-=150px'}, 2000, 'linear');
});

$('#swing').toggle(function() {
$('p').animate({'height':'-=150px'}, 2000, 'swing');
}, function() {
$('p').animate({'height':'+=150px'}, 2000, 'swing');
});

</script>

</body>
</html>  

Comments

  1. I see your "brief description on linear and swing easing methods", but I don't see your tutorial. There is just your code, script and html, "Download Demo" link is dead as well.
    Is this a live work in progress?
    Is the tutorial still to come?

    ReplyDelete
    Replies
    1. Hey Unknown thanks for pointing out
      i have updated the download link for easing tutorial

      Delete

Post a Comment

Thanks for Visiting for any questions or suggestions please comment below
Cheers,

Popular posts from this blog

Adding a button in HTML | styling a button

To add a button in a HTML page use <input> tags and specify the type as button like so
<input type=”button” value=”submit” action=”submit.php”> this code will be rendered in browser like in Figure 1.1
Further more if you wish to style this button we can apply a set of CSS rules to make the buttons look pretty here are a few examples: Download code for these buttons here



CSS Sprites | What are They?

CSS Sprites most web developers should have heard this term, so what is it ?.
CSS Sprite bunch of other images transformed into one Big Image. The origin of the term "sprites" comes from old school computer graphics and the video game industry. The idea was that the computer could fetch a graphic into memory, and then only display parts of that image at a time, which was faster than having to continually fetch new images.

Adding Sprites to our websites helps with webpage performance, since the webpage has to make only one request to the server, which will fetch the Sprite (the Big image) which includes all the other images that you want to use in your webpage. since the server makes only one request your page will load a lot faster compared to conventional way of linking each images separately.

Here is a demo on how to use CSS Sprites. further more there a many Sprite generators online to create CSS Sprites all you have to do is upload a bunch of images to these Online tools a…