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:
- <script type="Text/javascript" language="javascript" src="Js/jquery.js"> </Script>
- <script type="Text/javascript" language="javascript" src="Js/easing.js"> </Script>
- <script language="javascript" type="Text/javascript">
- $ (document). Ready (function () {
- $ ("#xxxx"). Stop (True,false). Animate ({left: -320},1500, ' easeoutelastic ');
- })
- </Script>
Get started with jquery easing
Method 1, set the jquery default animation effect
- 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:
- $ (Element). Slideup ({
- duration:1000,
- Easing:method,
- 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:
- $ (myelement). Animate ({
- LEFT:500,
- top:500
- }, ' Easeoutexpo ');
- James Padolsey has modified the animate function of jQuery1.3.2 to extend:
- JQuery.fn.animate = (function (_anim) {
- var jqeasing = jquery.easing;
- return function (prop, duration, easing, callback) {
- var props = {}, Optall, I, haseaser = false;
- For (i in prop) {
- if (Jquery.isarray (Prop[i])) {
- Haseaser = true;
- Props[i] = prop[i][1];
- Prop[i] = prop[i][0];
- }
- }
- opt = jquery.speed (duration, easing, callback);
- if (Haseaser) {
- Opt.step = (function (_step) {
- return function (now, FX) {
- var end = Fx.end, easefn;
- if ( easefn = Props[fx.prop]) {
- Fx.now = Jqeasing[easefn] (now/end, now, 0, end, end);
- }
- _step && _step.call (Fx.elem, Fx.now, FX);
- };
- }) (Opt.step);
- }
- optopt.complete = Opt.old | | callback | | jquery.isfunction (easing) && easing;
- Return _anim.call (this, prop, opt);
- };
- }) (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:
- $ (myelement). Animate ({
- LEFT:500,
- Top: [$, ' easeoutbounce ']
- }, +, ' swing ');
jQuery1.4 Animate () +easing
- JQuery (myelement). Animate ({
- Left: [$, ' swing '],
- Top: [$, ' easeoutbounce ']
- });
- Or:
- JQuery (myelement). Animate ({
- LEFT:500,
- top:200
- }, {
- Specialeasing: {
- Left: ' Swing ',
- Top: ' Easeoutbounce '
- }
- });
The animation of jquery+easing slow motion used in the front-end of website construction