automatic gallery carousel - Free Download Minimalist Automatic Gallery Carousel In jQuery

Free Download Minimalist Automatic Gallery Carousel In jQuery

Posted on

This time I will share jQuery Plugin and tutorial about Minimalist Automatic Gallery Carousel In jQuery, hope it will help you in programming stack.

automatic gallery carousel - Free Download Minimalist Automatic Gallery Carousel In jQuery
File Size: 9.77 KB
Views Total: 1117
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

An ultra-light, fully responsive, full-width, and jQuery based gallery carousel plugin that infinitely loops through a group of images at a given interval.

Just weights in less 1kb and works with 14 lines of JavaScript (jQuery) code.

How to use it:

1. Add images to the carousel slider.

01 <div class="slider">
02   <div class="inner">
03     <img src="1.jpg" alt="Alt 1" />
04     <img src="2.jpg" alt="Alt 2" />
05     <img src="3.jpg" alt="Alt 3" />
06     <img src="4.jpg" alt="Alt 4" />
07     <img src="5.jpg" alt="Alt 1" />
08     ...
09   </div>
10 </div>

2. The CSS to make the carousel slider full width.

1 body .slider .inner {
2   position: relative;
3   white-space: nowrap;
4   transition: all 1s ease;
5 }
6  
7 body .slider .inner img {
8   width: 100vw;
9 }

3. Load the necessary jQuery JavaScript library at the end of the HTML document.

1 <script src="/path/to/cdn/jquery.slim.min.js"></script>

4. The JavaScript (jQuery script) to activate the carousel slider.

01 (function(){
02     let left = 0
03     let cont = 1
04     const imagesToShow = parseInt($(".inner *").length)
05     setInterval(()=>{ 
06       if (cont++ <= imagesToShow){
07         $(".inner").css("left",${left}vw)
08         left -= 100
09         } else{
10           cont = 1
11           left = 0
12         }
13     },2000)
14 })()