Swipe js– mobile Web page content Touch Sliding class Library

Source: Internet
Author: User

Swipe.js Documentation and usage

Today brings a lightweight JS touch sliding class library-swipe JS, which is a very small JavaScript class library, but his function is not simple, it can be used to display any content on the Web page, support the precise touch movement operation, but also can set the automatic play, such as proportional scaling and other practical functions;

First, usage

Swipe just add a very simple piece of code, as follows

<div id='Slider' class='Swipe'> <divclass='Swipe-wrap'> <divclass='Wrap'></div> <divclass='Wrap'></div> <divclass='Wrap'></div> </div></div>

The above code is the original structure needed--a series of elements wrapped in two containers, you can add any of the content you want in wrap. The outermost div (i.e. slide) needs to be set up with the JS function:

Window.myswipe = Swipe (document.getElementById ('slider'));

Similarly, swipe needs to add some code to the style sheet

. swipe {  Overflow:hidden;  Visibility:hidden;  Position:relative;}. Swipe-wrap {  overflow:hidden;  Position:relative;}. Swipe-wrap > div {  float: left;  Width:%;  position:relative;}

Second, swipe function introduction

Below for you to introduce the use of swipe JS, swipe has the following parameters:

 startslide: 4 , //  The index position of the start picture Toggle  Auto: 3000 , //  Set automatic switchover time in milliseconds  continuous: true , //   picture transition effect with infinite looping  disablescroll: true  , //  stop scrolling through the screen because of touch  stoppropagation: false , //  stop sliding event  callback: function (index, Element) {}, //  callback function, trigger on toggle  transitionend:function (index, Element) {} //  callback function, the function is called at the end of the switch. 

In addition, there are some more API methods to use, such as:

    • Prev (): prev
    • Next (): Next page
    • GetPos (): Gets the index of the current page
    • Getnumslides (): Gets the number of all items
    • Slide (Index, duration): Sliding method

Finally set the JS binding and parameter settings:

The var slider = Swipe (document.getElementById ('slider'), {   ...   . ... ...});

or For example

New Swipe (document.getElementById ('slider'), {  2,    - ,    the ,   true ,   false ,   false ,  callback:function (index, elem) {},  transitionend:function (index, Elem) {}});

Instance effects can be viewed: http://www.jiawin.com/demos/swipe-mobile-touch-slider/index.html

Instance effect Download URL: http://yunpan.cn/QazPw6F4mZKH6

Swipe js– mobile Web page content Touch Sliding class Library

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.