Seamless scroll plug-in based on jQuery pictures left and right, need friends can refer to the Online Demo: http://demo.jb51.net/js/2012/myslideLeftRight/
Package download: http://www.jb51.net/jiaoben/44973.html
Core code:
The Code is as follows:
(Function ($ ){
$. Fn. extend ({
"Slidelf": function (value ){
Value = $. extend ({
"Prev ":"",
"Next ":"",
"Speed ":""
}, Value)
Var dom_this = $ (this). get (0); // converts a jquery object to a DOM object so that it can be called in other functions;
Var marginl = parseInt ($ ("ul li: first", this).css ("margin-left"); // The value of margin for each image
Var movew = $ ("ul li: first", this). outerWidth () + marginl; // The value to slide.
// Animation on the left
Function leftani (){
$ ("Ul li: first", dom_this). animate ({"margin-left":-movew}, value. speed, function (){
Vertex (this).css ("margin-left", marginl). appendTo ($ ("ul", dom_this ));
});
}
// Animation on the right
Function rightani (){
$ ("Ul li: last", dom_this). prependTo ($ ("ul", dom_this ));
$ ("Ul li: first", dom_this).css ("margin-left",-movew). animate ({"margin-left": marginl}, value. speed );
}
// Click on the left
$ ("." + Value. prev). click (function (){
If (! $ ("Ul li: first", dom_this). is (": animated ")){
Leftani ();
}
});
// Click on the left
$ ("." + Value. next). click (function (){
If (! $ ("Ul li: first", dom_this). is (": animated ")){
Rightani ();
}
})
}
});
}) (JQuery)
Ideas:
Click --
1. Slide the first LI to the left. The sliding value is the width of LI. (Here we use negative margin-left to move .)
2. After sliding, insert the LI into the last of the entire LI (seamless scrolling)
Click --
1. Insert the last LI into the first of all LI and locate it outside of the visible area (margin is used here)
2. Then slide it to the visible area.
Note: The IF judgment statement here is a BUG that occurs to prevent the "Left" or "right" button from being clicked consecutively;
The moving function is executed only when LI is not animated. As long as you are in the animation status, nothing happens when you click.