blog icon indicating copy to clipboard operation
blog copied to clipboard

How to show lightbox in React

Open onmyway133 opened this issue 4 years ago • 1 comments

Use https://github.com/biati-digital/glightbox

Configure css. Specify class='glightbox for html elements

<link rel="stylesheet" href="css/blueimp-gallery.min.css" />

Install package

npm install glightbox
import GLightbox from 'glightbox'
const lbElements = features.map((feature) => {
    return {
        'href': require(`../apps/${app.slug}/${feature.image}`),
        'type': 'image',
        'title': feature.title,
        'description': feature.texts[0],
    }
})

const openLb = () => {
    const lightbox = GLightbox({
        touchNavigation: true,
        loop: true,
        autoplayVideos: true,
        onOpen: () => {},
        beforeSlideLoad: (slide, data) => {}
    });
    
    const myGallery = GLightbox({
        elements: lbElements,
        autoplayVideos: false,
    });
    myGallery.open()
}}

onmyway133 avatar May 07 '20 05:05 onmyway133

Very nice, thank you

doe-base avatar Jul 29 '22 07:07 doe-base