Js achieves slideshow image effects that support mobile phone sliding Switching
This example describes how js achieves slideshow effects that support mobile phone slide switching. Share it with you for your reference. The details are as follows:
The running effect is as follows:
Click here to download the complete instance code.
Case study:
?
1 2 3 4 5 6 7 |
<Script type = "text/javascript" src = "../src/zepto. js"> </script> <Script type = "text/javascript" src = "../src/carousel-image.js"> </script> <Script> $ ('. Usel-image'). cancuselimage ({ Num: $ ('. Invalid usel-num ') }); </Script> |
Or requirejs:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<Div class = "carousel-image"> <Div> <A> </A> <A> </A> <A> </A> </Div> <Div class = "carousel-num"> </Div> </Div> <Script type = "text/javascript" src = "../src/zepto. js"> </script> <Script type = "text/javascript" src = "../src/require. js"> </script> <Script> Requirejs. config ({ // By default load any module IDs from js/lib BaseUrl: '../src ', Paths :{ $: 'Zepto' } }); Require (['usel-image', "$"], function (CarouselImage, $ ){ Var cs = new CarouselImage (); Cs. init ({ Target: $ ('. usel-image '), Num: $ ('. Invalid usel-num ') }); }); </Script> |
API attributes, methods, and callbacks:
Target:
It indicates that the element in the container will trigger the event. It should have a sub-level container to facilitate animation optimization.
Num:
The intention is to display the number of the current index, but now the number is hidden with the style, if you want to display the digital style, you can change the style File
I hope this article will help you design javascript programs.