The animation of jquery+easing slow motion used in the front-end of website construction

Source: Internet
Author: User

Web site construction of the front-end personnel to use jquery to achieve the animation is simple, but to achieve a more cool effect also need plug-in to help, easing is a help jquery to achieve slow animation plug-in, after trial, the effect is very good!

Download the plugin: jquery.easing.1.3.js jquery.easing.compatibility.js

The plug-in beautification after the layout is about 130 lines, compressed after smaller. This plugin makes up for the lack of animation effect in jquery, it is more powerful animation effect.

The x-axis represents time, and the y-axis represents the change in animation effects. Looking at these curve changes, it is more advantageous to grasp the effect of this plugin.

Plugin Support station: http://gsgd.co.uk/sandbox/jquery/easing/

Effect Demo site: http://james.padolsey.com/demos/jquery/easing/

We can see the performance of the performance demonstration site, or through the visual effects of coordinate labeling to understand the specific trajectory of its operation. For example:

Common parameters:
    • Linear
    • Swing
    • Jswing
    • Easeinquad
    • Easeoutquad
    • Easeinoutquad
    • Easeincubic
    • Easeoutcubic
    • Easeinoutcubic
    • Easeinquart
    • Easeoutquart
    • Easeinoutquart
    • Easeinquint
    • Easeoutquint
    • Easeinoutquint
    • Easeinsine
    • Easeoutsine
    • Easeinoutsine
    • Easeinexpo
    • Easeoutexpo
    • Easeinoutexpo
    • Easeincirc
    • Easeoutcirc
    • Easeinoutcirc
    • Easeinelastic
    • Easeoutelastic
    • Easeinoutelastic
    • Easeinback
    • Easeoutback
    • Easeinoutback
    • Easeinbounce
    • Easeoutbounce
    • Easeinoutbounce

Method Description:

    • DEF: default Mode setting
    • Swing: Load By default
    • Quad: Two-time square easing (t)
    • Cubic: Three-time Square easing
    • Quart: Four-time Square easing
    • Quint: Five-time Square easing
    • Sine: sinusoidal easing
    • Expo: exponential curve easing
    • CIRC: Easing of circular curves
    • Elastic: Exponential attenuation of sinusoidal easing
    • Back: three-square easing over range
    • Bounce: Exponential attenuation of rebound easing

Description of In, out, InOut:

    • Easein: acceleration easing;
    • Easeout: slow speed reduction;
    • EaseInOut: First acceleration to 50%, then reduce the speed to complete the animation.
How to apply:

Slideup|slidedown|slidetoggle|fadein|fadeout|fadetoggle

$ (Element). Slideup (Duration,easing,[callback]);

FadeTo

$ (Element). FadeTo (Duration,opacity,easing,[callback]);

Animate

$ (Element). Animate ({properties},duration,easing,callback);

The jquery1.4+ version can also:

$ (Element). Animate ({left:[100, ' Swing '],top:[100, ' easeoutbounce '});

Or

JQuery (myelement). Animate ({left:100,top:100},{specialeasing:{left: ' Swing ', Top: ' Easeoutbounce '}});

Refer to the Jquery1.4+ API for more details.

Simple example:

  1. <script type="Text/javascript" language="javascript" src="Js/jquery.js"> </Script>
  2. <script type="Text/javascript" language="javascript" src="Js/easing.js"> </Script>
  3. <script language="javascript" type="Text/javascript">
  4. $ (document). Ready (function () {
  5. $ ("#xxxx"). Stop (True,false). Animate ({left: -320},1500, ' easeoutelastic ');
  6. })
  7. </Script>

Get started with jquery easing

Method 1, set the jquery default animation effect

    1. JQuery.easing.def = "method";//such as: Easeoutexpo

Method 2, jquery default animation

Supports toggle (), Slideup (), Slidedown (), show (), Hide (), and other jquery-built animation effects

such as the following code:

    1. $ (Element). Slideup ({
    2. duration:1000,
    3. Easing:method,
    4. Complete:callback});

Method 3, use jquery to customize the animation function. Animate ()

JQuery's. Animate () is a function of custom animation, as stated above, with four parameters, where easing's parameter is the name of the method (such as Easeoutexpo) in which we animate the effect. The simplest way to use web site construction is to:

  1. $ (myelement). Animate ({
  2. LEFT:500,
  3. top:500
  4. }, ' Easeoutexpo ');
  5. James Padolsey has modified the animate function of jQuery1.3.2 to extend:
  6. JQuery.fn.animate = (function (_anim) {
  7. var jqeasing = jquery.easing;
  8. return function (prop, duration, easing, callback) {
  9. var props = {}, Optall, I, haseaser = false;
  10. For (i in prop) {
  11. if (Jquery.isarray (Prop[i])) {
  12. Haseaser = true;
  13. Props[i] = prop[i][1];
  14. Prop[i] = prop[i][0];
  15. }
  16. }
  17. opt = jquery.speed (duration, easing, callback);
  18. if (Haseaser) {
  19. Opt.step = (function (_step) {
  20. return function (now, FX) {
  21. var end = Fx.end, easefn;
  22. if ( easefn = Props[fx.prop]) {
  23. Fx.now = Jqeasing[easefn] (now/end, now, 0, end, end);
  24. }
  25. _step && _step.call (Fx.elem, Fx.now, FX);
  26. };
  27. }) (Opt.step);
  28. }
  29. optopt.complete = Opt.old | | callback | | jquery.isfunction (easing) && easing;
  30. Return _anim.call (this, prop, opt);
  31. };
  32. }) (jQuery.fn.animate);

This approach has been introduced in jQuery1.4, so there is no need to add the animate () extension of jquery in jQuery1.4, so we can use the following more convenient code:

    1. $ (myelement). Animate ({
    2. LEFT:500,
    3. Top: [$, ' easeoutbounce ']
    4. }, +, ' swing ');

jQuery1.4 Animate () +easing

    1. JQuery (myelement). Animate ({
    2. Left: [$, ' swing '],
    3. Top: [$, ' easeoutbounce ']
    4. });
    5. Or:
    6. JQuery (myelement). Animate ({
    7. LEFT:500,
    8. top:200
    9. }, {
    10. Specialeasing: {
    11. Left: ' Swing ',
    12. Top: ' Easeoutbounce '
    13. }
    14. });

The animation of jquery+easing slow motion used in the front-end of website construction

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.