Home > Web Front-end > JS Tutorial > js implementation example of carousel image effect that supports mobile phone sliding switching_javascript skills

js implementation example of carousel image effect that supports mobile phone sliding switching_javascript skills

WBOY
Release: 2016-05-16 16:01:50
Original
1628 people have browsed it

The example in this article describes the method of using js to implement a carousel image effect that supports sliding switching on mobile phones. Share it with everyone for your reference. The details are as follows:

The operation effect is as follows:

Click here for the complete example codeDownload from this site.

Usage examples:

<script type="text/javascript" src="../src/zepto.js"></script>
<script type="text/javascript" src="../src/carousel-image.js"></script>
<script>
 $('.carousel-image').CarouselImage({
  num :$('.carousel-num')
});
</script>
Copy after login

or requirejs:

<div class="carousel-image">
<div>
 <a>
  <img src="http://www.yoursiteweb.com/images/1430073193462.jpg"/>
 </a>
 <a>
  <img src="http://www.yoursiteweb.com/images/1430073252953.png"/>
 </a>
 <a>
  <img src="http://www.yoursiteweb.com/images/1430073111420.jpg"/>
 </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(['carousel-image',"$"], function(CarouselImage,$) {
  var cs = new CarouselImage();
  cs.init({
   target:$('.carousel-image'),
   num:$('.carousel-num')
  });
});
</script>
Copy after login

API properties, methods and callbacks:

target:
Indicates that the element in this container will trigger the event. It should have child containers to facilitate animation optimization

num:
The original intention is to display the number of the current index, but now the number is hidden by the style. If you want to display the number style, you can change the style file yourself

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template