Jquery Image Display

Source: Internet
Author: User

ForwardBackward

About

I found this when I just sorted the hard disk. When I first saw a GIF on the internet, I changed it to the jquery version.

Structure
<Div id = "flow">           </ div> <button id = "Forward"> forward </button> <button id = "backward"> backward </button>
Style
<style type="text/css">#flow{position:relative; width:700px; height:480px;background:#300;border:1em solid #333;}#flow img{ position:absolute;width:260px; height:338px; display:none; }</style>
How to do

First, three new arrays are created to save the image object list, the style and serial number of each position:

var $imgList    = [];var styleList   = [];var tmp         = [0..n];

Then, in order to ensure smooth page loading, use the special effect of an animation queue for initialization:

// Queue name var Qn = 'initquene '; var init = function () {$ flow. dequeue (qN);} // create a queue $ flow during initialization. queue (qN, function () {$ imglist [N]. styleanimate (stylelist [N], config. initspeed, init );});});

Here is the most critical step. during initialization, you can fill in the three arrays used for caching in sequence.

Furthermore, in order to make the pictures look better, we should use non-linear distance intervals:

var interval = (Math.pow(zIndex, config.exp) - 1) * ((fw - iw) / 2) / (Math.pow(half, config.exp) - 1);

Finally, when moving an image, you can use a function similar to the following loop Array Function to control the sequence and movement interval of the image:

  Array.prototype.loop = function(num) {var step = Math.abs(isNaN(num) ? 1 : num % this.length);return num > 0 ? this.concat(this.splice(0, step)): this.splice(-step).concat(this);};$.each(tmp.loop(-3), function(i, n) {$imgList[n].stop().styleAnimate(styleList[i], config.playSpeed);});
Call
$ (Function () {// For more configuration parameters, see the upper layer of the plug-in $ ('# flow'). imgflow ();});
Download

Jquery. imgflow. js

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.