JQuery-Based Seamless scrolling between left and right _ jquery

Source: Internet
Author: User
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.
Related Article

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.