JS simple carousel image scrolling instance. For more information, see [javascript].
The Code is as follows:
Var forimg = function (foritem, hoverStop, defaultfor ){
Var _ foritem = foritem. constructor = jQuery? Foritem: $ (foritem );
Var imgarr = [
{"Z-index": 1, "width": 100, "height": 100, "left": 0, "top": "75px "},
{"Z-index": 2, "width": 200, "height": 200, "left": 50, "top": "25px "},
{"Z-index": 3, "width": 300, "height": 250, "left": 150, "top": "0 "},
{"Z-index": 2, "width": 200, "height": 200, "left": 370, "top": "25px "},
{"Z-index": 1, "width": 100, "height": 100, "left": 520, "top": "75px "}
];
_ Foritem. each (function (I ){
Var _ this = $ (this );
_This.css (imgarr [I] | imgarr [4]);
_ This. find ("img" cmd.css (imgarr [I] | imgarr [4]);
}); Www.jb51.net
Var _ for = function (_ I, data, nulldata, callback ){
$ (Foritem). each (function (I ){
Var self = $ (this );
SetTimeout (function (){
Self.css ("z-index", (data [I + _ I] | nulldata) ["z-index"])
Self. stop (). animate (data [I + _ I] | nulldata );
Self. find ("img"). stop (). animate (data [I + _ I] | nulldata, function (){
Callback. call (self, I );
});
});
});
};
Var that = this;
Var defaultforfun = function (){
If (! Defaultfor ){
That. leftfor ();
} Else {
That. rightfor ();
}
}
Var forimgInterval = setInterval (defaultforfun, 1000 );
If (hoverStop ){
_ Foritem. hover (function (){
ClearInterval (forimgInterval );
}, Function (){
For imginterval = setInterval (defaultforfun, 1000 );
});
}
This. leftfor = function (){
Var nuldata = {"z-index":-1, "width": 100, "height": 100, "left": 520, "top": "75px "};
Imgarr [0] ["z-index"] = 1;
Imgarr [0] ["z-index"] = 2
Imgarr [0] ["z-index"] = 3
Imgarr [0] ["z-index"] = 2
Imgarr [0] ["z-index"] = 1
_ For (-1, imgarr, nuldata, function (I ){
If (I = 0 ){
This. closest ("ul"). append (this );
}
});
};
This. rightfor = function (){
Var nuldata = {"z-index":-1, "width": 100, "height": 100, "left": 0, "top": "75px "};
Imgarr [0] ["z-index"] = 1;
Imgarr [0] ["z-index"] = 2
Imgarr [0] ["z-index"] = 4
Imgarr [0] ["z-index"] = 5
Imgarr [0] ["z-index"] = 2
_ For (1, imgarr, nuldata, function (I ){
If (I = _ foritem. length-1 ){
This. closest ("ul"). prepend (this );
This.css ("z-index", "1 ");
}
});
};
This. stop = function (){
ClearInterval (forimgInterval );
};
This. next = function (){
For imginterval = setInterval (defaultforfun, 1000 );
};
};