baguetteBox.js---Simple and easy to use lightbox script


BaguetteBox.js is a simple and easy to use lightbox script. 

GitHub here


Step1:
link baguetteBox.css and js file
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.8.2/baguetteBox.min.css">
 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.8.2/baguetteBox.min.js"></script>
Step2:
html
Thubnail image should be inside the link which is the original one.

data-caption is the words showing below the picture.

<div class="gallery">
    <a href="img/2-1.jpg" data-caption="Image caption">
        <img src="img/thumbs/2-1.jpg" alt="First image">
    </a>
    <a href="img/2-2.jpg">
        <img src="img/thumbs/2-2.jpg" alt="Second image">
    </a>
    ...
</div>

The basic  styling:
css

Step3:
js
Apply the function with baguetteBox.run().

baguetteBox.run('.gallery', {
    // Custom options
});

The following options are available:
OptionTypeDefaultDescription
captionsBoolean | function(element)trueDisplay image captions. Passing a function will use a string returned by this callback. The only argument is a element containing the image. Invoked in the context of the current gallery array
buttonsBoolean | 'auto''auto'Display buttons. 'auto' hides buttons on touch-enabled devices or when only one image is available
fullScreenBooleanfalseEnable full screen mode
noScrollbarsBooleanfalseHide scrollbars when gallery is displayed
titleTagBooleanfalseUse caption value also in the gallery img.title attribute
asyncBooleanfalseLoad files asynchronously
preloadNumber2How many files should be preloaded
animation'slideIn' | 'fadeIn' | false'slideIn'Animation type
afterShowfunctionnullCallback to be run after showing the overlay
afterHidefunctionnullCallback to be run after hiding the overlay
onChangefunction(currentIndex, imagesCount)nullCallback to be run when image changes
overlayBackgroundColorString'rgba
(0,0,0,0.8)'
Background color for the lightbox overlay
filterRegExp`/.+.(gifjpe?g
More document detail find on GitHub




Popular posts from this blog

Fancyapps — easily build overlay windows with carousel

Meet Mantine: A TS-Based Open-Source React Components Library

Meet Tippy.js: The Complete Tooltip Popover Plugin