Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Understanding animation easing

From: jQuery for Web Designers

Video: Understanding animation easing

When you start playing with animation in jQuery or in CSS, pretty soon you're going to run into the term, easing, which we're going to talk about in this movie. So jumping down in my file to the JavaScript, I have this animation that moves my images around when I click a link. It takes two seconds to do this. So my animation method first takes the properties that I want to animate and then the duration. There's another argument that I can add for, what is called easing. In this context, easing is a mathematical function that determines how the animation progresses from beginning to end.

Understanding animation easing

When you start playing with animation in jQuery or in CSS, pretty soon you're going to run into the term, easing, which we're going to talk about in this movie. So jumping down in my file to the JavaScript, I have this animation that moves my images around when I click a link. It takes two seconds to do this. So my animation method first takes the properties that I want to animate and then the duration. There's another argument that I can add for, what is called easing. In this context, easing is a mathematical function that determines how the animation progresses from beginning to end.

So that is, how fast it is at certain parts and how slow it is at other parts. The way we work with these is calling them by name, by a string. So if I want to set my easing on this animation, I just pass the string with the name that I one want. jQuery has two built in, the one it uses, if you don't specify any easing function, is called swing and with this one your animation starts, it kind of speeds up and then slows down toward the end. The other one that's build in is called linear and I am going to add this one in now and save this and switch over to my browser and reload this page.

Now when I click the image you will see that over the course of the animation the speed does not change. It just proceeds without changing the whole way over. Let's see if you can see the difference, I change this back to swing and reload. So the difference between these two is pretty settled I think, its there but it's kind of settled. So, those are the two they are just built into jQuery, but there are lots, lots more available. There are two main sources for adding easing functions into your jQuery. One of them is the jQuery easing plugin which is just a standalone plugin that gives you a whole bunch more easing functions.

There about 30 easing functions that it adds in for you. Another path of the way is to use jQuery UI, the jQuery UI is rather a big plugin, so if all you really want is easing, you could just grab this plugin and install it just the way we looked at color box. Another site I want to point you to is easings.net. This is a nice visualizer that shows you all of the easing functions that are built into the jQuery easing plug in. And also, quite a lot of these are usable in CSS3 animations. This last row, if you hover over here. You can see that those six are only available when you're using JavaScript via the jQuery easing plug in.

But all the rest of these are available if you're using CSS as well. And if you watch when I mouse over these, the little arrow moves using that easing plugin. You can see some of these are a little slow at the beginning and then ramp up real fast. There's all these different ways that this thing can go. Now, as it happens, this sample site has the jQuery easing plug in already built in. So let's try some of the more dramatic examples. And you can see how easing effects the way an animation looks. Let's grab this one, I'm going to copy its name. Switch over to my editor and plug it in here.

Just to make it a little more dramatic, I'm going to make this animation take three seconds instead of two. Switch back over to the browser and reload this page. Now watch what happens. It's kind of herky jerky, wobbles back and forth. But gets to the same place and it takes the same amount of time. It's just that the properties that I've asked it to animate, have that other function applied to them. So they get moved around a little bit as they proceed. Let's try another one, ease outbounds. Plug that in. And reload. So, with this one, you kind of bounce your way into the end of the animation.

Some of these, as you can see, are very dramatic. Most of the ones that are available in CSS, also, are much more subtle. I'll try this one. Reload again. So, wow, that one had a big effect, because it displaced a lot of stuff as it went. But you can see there are a lot of options available here. So again, this project has the jQuery easing plug in built in to this minimized plugins file. So you didn't have to install it separately. In another jQuery project that you're working on, you'll probably need to install it just the way you'd install any other plug in before you can start using it.

And of course, as I mentioned, many of these easing effects are available if you use CSS animations. So if you want to combine CSS and jQuery, you could do it that way. But that's a look at what easing functions are and how you can start using them in your jQuery animations.

Show transcript

This video is part of

Image for jQuery for Web Designers
jQuery for Web Designers

37 video lessons · 11344 viewers

Joe Chellman
Author

 
Expand all | Collapse all
  1. 2m 17s
    1. Welcome
      1m 4s
    2. What you should know
      37s
    3. Using the exercise files
      36s
  2. 12m 0s
    1. jQuery is a JavaScript library?
      1m 15s
    2. When to use jQuery
      2m 51s
    3. Alternatives to jQuery
      1m 25s
    4. Which version of jQuery to use
      1m 50s
    5. How to install jQuery
      3m 21s
    6. Reference materials
      1m 18s
  3. 19m 19s
    1. Getting ready
      2m 26s
    2. Selecting elements to use
      3m 54s
    3. Performing multiple operations on the same line with chaining
      2m 30s
    4. Using classes to find what you're looking for
      3m 52s
    5. Adding, modifying, and removing content dynamically
      4m 3s
    6. Challenge: Form feedback
      1m 12s
    7. Solution: Form feedback
      1m 22s
  4. 18m 28s
    1. Triggering a change based on activity with event binding
      4m 37s
    2. Reading and changing values
      4m 17s
    3. Working with HTML attributes
      4m 55s
    4. Challenge: Dynamic contact form
      1m 27s
    5. Solution: Dynamic contact form
      3m 12s
  5. 16m 42s
    1. Using the Colorbox plugin to build a slideshow gallery
      4m 22s
    2. Implementing Colorbox on your site
      2m 46s
    3. Changing Colorbox options
      5m 53s
    4. Challenge: Convert to a slideshow
      1m 6s
    5. Solution: Convert to a slideshow
      2m 35s
  6. 28m 37s
    1. Using jQuery or CSS to animate elements
      2m 24s
    2. Creating simple jQuery animations
      4m 35s
    3. Animating numeric properties with animate()
      4m 56s
    4. Understanding animation easing
      4m 4s
    5. Putting it together: Flowers in the cart
      6m 4s
    6. Callbacks: What to do when the animation ends
      3m 27s
    7. Challenge: Improve the animation
      1m 3s
    8. Solution: Improve the animation
      2m 4s
  7. 4m 45s
    1. More fun plugins
      2m 38s
    2. What's next: More jQuery
      50s
    3. What's next: More JavaScript
      1m 17s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed jQuery for Web Designers.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.