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