Minimalist Automatic Gallery Carousel In jQuery
| File Size: | 9.77 KB |
|---|---|
| Views Total: | 2366 |
| 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.
<div class="slider">
<div class="inner">
<img src="1.jpg" alt="Alt 1" />
<img src="2.jpg" alt="Alt 2" />
<img src="3.jpg" alt="Alt 3" />
<img src="4.jpg" alt="Alt 4" />
<img src="5.jpg" alt="Alt 1" />
...
</div>
</div>
2. The CSS to make the carousel slider full width.
body .slider .inner {
position: relative;
white-space: nowrap;
transition: all 1s ease;
}
body .slider .inner img {
width: 100vw;
}
3. Load the necessary jQuery JavaScript library at the end of the HTML document.
<script src="/path/to/cdn/jquery.slim.min.js"></script>
4. The JavaScript (jQuery script) to activate the carousel slider.
(function(){
let left = 0
let cont = 1
const imagesToShow = parseInt($(".inner *").length)
setInterval(()=>{
if (cont++ <= imagesToShow){
$(".inner").css("left",`${left}vw`)
left -= 100
} else{
cont = 1
left = 0
}
},2000)
})()
This awesome jQuery plugin is developed by defaultuser001. For more Advanced Usages, please check the demo page or visit the official website.










