touch carousel scroll snap - Free Download Touch-enabled Carousel With jQuery And CSS Scroll Snap - Snapper

Free Download Touch-enabled Carousel With jQuery And CSS Scroll Snap – Snapper

Posted on

This time I will share jQuery Plugin and tutorial about Touch-enabled Carousel With jQuery And CSS Scroll Snap – Snapper, hope it will help you in programming stack.

touch carousel scroll snap - Free Download Touch-enabled Carousel With jQuery And CSS Scroll Snap - Snapper
File Size: 905 KB
Views Total: 2175
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

snapper is a small jQuery slider plugin to create a fully responsive, mobile-friendly, fully configurable carousel component using CSS Scroll Snap feature.

Main features:

  • Supports touch events.
  • Arrows navigation.
  • Thumbnail navigation.
  • Keyboard interactions.
  • Autoplay.
  • Allows multiple items per slide.
  • Auto updates the location hash when slides change or not.
  • Auto calculates and resizes items to fit the viewport.
  • You can find more demos in the zip.

How to use it:

1. Import the jQuery snapper plugin’s files into the document. The plugin requires the latest jQuery library to work.

1 <link rel="stylesheet" href="snapper.css" />
2 <script src="jquery.min.js"></script>
3 <script src="snapper.js"></script>

2. Load the toss.js library for smooth anchoring and scroll snapping (OPTIONAL).

1 <script src="toss.js"></script>

3. The basic HTML structure for the carousel. The OPTIONAL snapper_pane_crop class is used to hide the scrollbar when using thumbnail navigation.

01 <div class="snapper">
02   <div class="snapper_pane_crop">
03     <div class="snapper_pane">
04       <div class="snapper_items">
05         <div class="snapper_item" id="img-a">
06           <img src="a.jpg" alt="">
07         </div>
08         <div class="snapper_item" id="img-b">
09           <img src="b.jpg" alt="">
10         </div>
11         <div class="snapper_item" id="img-c">
12           <img src="c.jpg" alt="">
13         </div>
14         ...
15       </div>
16     </div>
17   </div>
18 </div>

4. Call the plugin to initialize the carousel. Done.

1 $(function(){
2   $(document).trigger("enhance");
3 });

5. Add a thumbnail navigation to the bottom of the carousel.

1 <div class="snapper_nav">
2   <a href="#img-a"><img src="a-thmb.jpg" alt=""></a>
3   <a href="#img-b"><img src="b-thmb.jpg" alt=""></a>
4   <a href="#img-c"><img src="c-thmb.jpg" alt=""></a>
5   ...
6 </div>

6. Add navigation arrows to the carousel using the data-snapper-nextprev attribute:

1 <div class="snapper" data-snapper-nextprev>
2   ...
3 </div>

7. Add pagination bullets to the carousel:

1 <div class="snapper_nav snapper_nav-dots">
2   <a href="#img-a">Slide 1</a>
3   <a href="#img-b">Slide 2</a>
4   <a href="#img-c">Slide 3</a>
5 </div>

8. Add pagination bullets to the carousel:

1 <div class="snapper_nav snapper_nav-dots">
2   <a href="#img-a">Slide 1</a>
3   <a href="#img-b">Slide 2</a>
4   <a href="#img-c">Slide 3</a>
5 </div>

9. Show multiple items per slide using the data-snapper-setwidths attribute:

1 <div class="snapper" data-snapper-setwidths>
2   ...
3 </div>
01 @media (min-width: 30em){
02   .snapper-smallpoints  .snapper_item {
03     width: 50%;
04   }
05   .snapper-smallpoints  .snapper_pane {
06     -webkit-scroll-snap-points-x: repeat(50%);
07     -ms-scroll-snap-points-x: repeat(50%);
08     scroll-snap-points-x: repeat(50%);
09   }
10 }
11 @media (min-width: 50em){
12   .snapper-smallpoints  .snapper_item {
13     width: 33.333%;
14   }
15   .snapper-smallpoints  .snapper_pane {
16     -webkit-scroll-snap-points-x: repeat(33.33333%);
17     -ms-scroll-snap-points-x: repeat(33.33333%);
18     scroll-snap-points-x: repeat(33.33333%);
19   }
20 }

10. Enable the autoplay functionality using the data-snapper-autoplay attribute: