How to set URL for close button in LightGallery in React (NextJS)

98 views Asked by At

I have LightGallery on the URL /gallery/id, where I have opened the gallery yet. But If I click close gallery, I want to be redirected to /page/id. How can I do it?

My component in return function:

import LightGallery from 'lightgallery/react';
...

                 <LightGallery
                    onInit={(details) => {
                        onInit(details);
                    }}
                    speed={800}
                    plugins={[
                        lgThumbnail,
                        lgZoom,
                        video,
                        fullscreen,
                        comment,
                        autoplay,
                        rotate,
                    ]}
                    download={false}
                    videojs={true}
                    fullScreen={true}
                    enableThumbSwipe={true}
                    animateThumb={true}
                    enableThumbDrag={true}
                    toggleThumb={true}
                    closeOnTap={true}
                    enableDrag={true}
                    getCaptionFromTitleOrAlt={true}
                    mousewheel={true}
                    showMaximizeIcon={true}
                    showZoomInOutIcons={true}
                    mobileSettings={mobileSettingsProp}
                    autoplay={true}
                    autoplayControls={true}
                    progressBar={true}
                    rotate={true}
                    rotateRight={true}
                    elementClassNames={'gallery'}
                    zoomFromOrigin={false}
                    allowMediaOverlap={true}
                >
                    {photos}
                </LightGallery>

And onInit function:

    const onInit = useCallback((details: InitDetail) => {
        if (details && !details?.instance?.lgOpened) {
            lightGallery.current = details.instance;
            lightGallery.current?.openGallery(0);
        }
    }, []);
0

There are 0 answers