Tiny Yet Customizable Background Slideshow In jQuery
File Size: | 23.3 KB |
---|---|
Views Total: | 3747 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
A tiny (3kb minified) yet fully responsive and highly customizable jQuery background slideshow (Carousel) plugin that automatically cross-fades or scrolls between background images of your container element at a certain speed.
How to use it:
1. Download the plugin and insert the JavaScript file jquery-bg-slideshow.js
after loading the latest jQuery JavaScript library.
<script src="/path/to/cdn/jquery.slim.min.js"></script> <script src="/path/to/src/jquery-bg-slideshow.min.js"></script>
2. Call the function on the target container and specify an array of images for the backgrounds.
<div class="bg"> ... Any Content Here </div>
$(function() { $(".bg").bgSlideShow({ images : ["1.jpg", "2.jpg", "3.jpg" ] }); });
3. You can also initialize the background slideshow and pass options via HTML data
attributes:
<div class="bg" data-images="1.png,2.png,3.png"> ... Any Content Here </div>
4. Determine the image index the background slideshow should start with. Default: the first image.
<div class="bg" data-images="1.png,2.png,3.png" data-current="2"> ... Any Content Here </div>
// or $(".bg").bgSlideShow({ images : ["1.jpg", "2.jpg", "3.jpg" ], current: 0 });
5. Config the transition effect. All possible transition effects:
- fade-in (default)
- from-right
- from-left
<div class="bg" data-images="1.png,2.png,3.png" data-transitionDelay="5000" data-transitionSpeed="3000" data-transitionEffect="fade-in"> ... Any Content Here </div>
// or $(".bg").bgSlideShow({ images : ["1.jpg", "2.jpg", "3.jpg" ], transitionDelay: 5000, transitionSpeed: 3000, transitionEffect: 'fade-in' });
6. Determine whether to randomize the image the background slideshow starts with. Default: false.
<div class="bg" data-images="1.png,2.png,3.png" data-randomize="true"> ... Any Content Here </div>
// or $(".bg").bgSlideShow({ images : ["1.jpg", "2.jpg", "3.jpg" ], randomize: true });
7. Apply an initial background image to the container.
<div class="bg" data-images="1.png,2.png,3.png" data-initialBackground="/path/to/image/"> ... Any Content Here </div>
// or $(".bg").bgSlideShow({ images : ["1.jpg", "2.jpg", "3.jpg" ], initialBackground: '/path/to/image/' });
8. Determine whether to display pagination bullets at the bottom of the slideshow.
$(".bg").bgSlideShow({ slideControls: { enabled: true, classes: null } });
9. Available event handlers.
$(".bg").bgSlideShow({ images : ["1.jpg", "2.jpg", "3.jpg" ], eventHandlers: { // before initialization beforeInit: null, // after initialization afterInit: null, // before the current image is replaced beforeChange: null, // after the current image is replaced afterChange: null } });
Changelog:
2021-02-01
- Bug fixed
2020-12-13
- Created a method to see if bgSlideshowApplied
This awesome jQuery plugin is developed by sunil-samuel. For more Advanced Usages, please check the demo page or visit the official website.