12 Pdf-Of-Presentation WEB1091 M02 Jquery Effects Library
12 Pdf-Of-Presentation WEB1091 M02 Jquery Effects Library
Library
Important Considerations
Generally, it is better to do animation in CSS,
if at all possible. When animation is done in
CSS, the computer’s GPU can be used to help
with the processing of the animation.
Example 1 has some basic HTML and some CSS to make it look good.
Example 1 - Hide Function
One of the really great features of the jQuery To add the callback function, just put a
effects library is the ability to add a “callback comma after the speed of the animation and
function”. then add an additional anonymous function.
We will talk more about callback functions Inside the curly braces for the new
later, but for now, know that this function anonymous function, you can put code for
runs when the animation is finished. what you want to happen when the animation
finishes.
Example 1 - Callback With Formatting
You can see I had already added the easing The easeOutBounce easing is more dramatic
plugin from the CDN. You can find out more than the simple swing easing.
about the plugin on the jQuery Easing Plugin
website.
Example 2 - With Callback
Finally, you can add the callback after the easing parameter.
Example 3 - HTML
Here is the HTML for example 3. It looks jQuery has convenient built in function for
similar to the others. fading in, fading out and fading to a specific
opacity.
Example 3 - Fading Script
These scripts look similar to the others. Of This number is between 0 and 1, where zero
note, the fadeTo method takes an extra is completely transparent and 1 is completely
parameter to determine the amount of opaque. So 0.2 is 20% opacity.
opacity
Example 3 - With Easing and Callback
You can add the easing and the callback function parameters after the amount of
opacity for the fadeTo method.
Example 4 - HTML
The HTML and CSS for example 4 have In this example you will experiment with the
changed a little. custom jQuery animation function.
Example 4 - Custom Animate Method
Pass an object into the custom animate Before we really get into objects in more
method. You have not yet learned about detail, you will see a few examples of them
objects in JavaScript in this course yet, but you pop up in our scripts.
will find out more about them soon.
Example 4 - Font Size
This is for the second button. Notice that font This is again because font-size would look to
size, which in CSS is font-size, has been JavaScript like you want to subtract size from
changed to the JavaScript equivalent here of font, which is not what you mean to do at all.
fontSize
Example 4 - Setting Left Property
To get each animation to run in a sequence, This is the hardest one to type. Be sure to go
you just have to put each one in a callback from the outside to the inside and be careful
function, in the order you want them to run. about formatting.
Summary
You can do a LOT with the built in effects
library, just keep in mind that adding and
removing CSS classes with animation is
generally the better way to go.