Swiper.js Initial involvement

Source: Internet
Author: User

To do a mobile phone-side carousel, studied a bit of swiper.js

Chinese website: http://www.swiper.com.cn/

English website: http://www.idangero.us/swiper/

Record the code:

var myswiper = new Swiper ('. Swiper-container ', {
Mode: ' Vertical ',//vertical direction of sliding direction
Pagination: '. Pagination ',
Onslideprev:function (Swiper) {
sdragdirection = ' down ';
},
Onslidenext:function (Swiper) {
sdragdirection = ' up ';
},
Onslidereset:function (Swiper) {
var iNum = 0;
if (sdragdirection = = ' down ') {
Console.log (' drag Down ');//ajax get data from the previous day
INum = 2;
sdragdirection = ' up ';
}
else if (sdragdirection = = ' up ') {
Console.log (' drag up ');//ajax gets the day after the data
INum = 0;
sdragdirection = ' down ';
}
var newSlide1 = myswiper.createslide (' <p> This is a new slide1</p> ', ' swiper-slide blue-slide ', ' div ');//Create Slide
Newslide1.append (); Add to Slides's last
var newSlide2 = myswiper.createslide (' <p> This is a new slide2</p> ', ' swiper-slide blue-slide ', ' div ');
Newslide2.append (); Add to Slides's last
var newSlide3 = myswiper.createslide (' <p> This is a new slide3</p> ', ' swiper-slide blue-slide ', ' div ');
Newslide3.append (); Add to Slides's last
var ilength = 3;
for (Var i=0;i<ilength;i++) {
Myswiper.removeslide (0); Delete the first three slide
}
Myswiper.swipeto (INum, 1, false);
}
})

This is the main use of

Onslideprev:function (Swiper) {} Up one swipe trigger event
Onslidenext:function (swiper) {} down a sliding trigger event
Onslidereset:function (swiper) {} slider does not reach a trigger event that is the last or the next one does not exist, triggering an event

Swiper.js Initial involvement

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.