Fancyapps slider gallery is not working with fancybox

Im trying to create a fancyapps slider gallery that on click opens fancybox gallery (lightbox). Fancybox is working fine but my slider gallery is displaying as a grid not as a slider. Any help is much appreciated.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>useEffect(() => {
if (offer?.Galeria?.length) {
const carouselElement = document.querySelector(".f-carousel");
new Carousel(carouselElement, {
Dots: true,
Navigation: true,
});
Fancybox.bind("[data-fancybox='gallery']", {
infinite: true,
});
}
return () => {
Fancybox.destroy();
const carouselElement = document.querySelector(".f-carousel");
if (carouselElement) {
carouselElement.Carousel?.destroy();
}
};
}, [offer]);
return (
<div>
<Navbar />
<div className="container-fluid">
<div className="col-md-8 mx-auto">
<h1>{offer.Tytul_oferty}</h1>
<p>{opis}</p>
<p>Powierzchnia: {offer.Powierzchnia}</p>
<p>Pokoje: {offer.Pokoje}</p>
<p>Cena: {offer.Cena} PLN</p>
<div className='f-carousel has-thumbs is-ltr'>
{offer.Galeria?.map((image, index) => (
<a
key={index}
data-fancybox="gallery"
href={image.url}
className={styles.carouselImage}
>
<img
src={image.url}
alt={image.altText || `Obraz ${index + 1}`}
className="img-fluid rounded"
/>
</a>
))}
</div>
</div>
</div>
<Footer />
</div>
);
'use client';
import { useEffect } from 'react';
import { Fancybox } from '@fancyapps/ui';
import '@fancyapps/ui/dist/fancybox/fancybox.css';
const FancyboxGallery = () => {
useEffect(() => {
Fancybox.bind('[data-fancybox="gallery"]', {
dragToClose: false,
Toolbar: {
display: {
left: ['infobar'],
middle: ['fullscreen'],
right: ['thumbs', 'close'],
},
},
Images: {
zoom: false,
},
Thumbs: {
type: 'modern',
},
Carousel: {
transition: 'fade', // Płynne przejścia
friction: 0, // Średni opór
infinite: true,
},
on: {
'Carousel.ready Carousel.change': (fancybox) => {
fancybox.container.style.setProperty(
'--bg-image',
`url("${fancybox.getSlide().thumbSrc}")`
);
},
},
});
// Cleanup Fancybox bindings when component is unmounted
return () => {
Fancybox.destroy();
};
}, []);
};
export default FancyboxGallery;
</code>
<code>useEffect(() => { if (offer?.Galeria?.length) { const carouselElement = document.querySelector(".f-carousel"); new Carousel(carouselElement, { Dots: true, Navigation: true, }); Fancybox.bind("[data-fancybox='gallery']", { infinite: true, }); } return () => { Fancybox.destroy(); const carouselElement = document.querySelector(".f-carousel"); if (carouselElement) { carouselElement.Carousel?.destroy(); } }; }, [offer]); return ( <div> <Navbar /> <div className="container-fluid"> <div className="col-md-8 mx-auto"> <h1>{offer.Tytul_oferty}</h1> <p>{opis}</p> <p>Powierzchnia: {offer.Powierzchnia} m²</p> <p>Pokoje: {offer.Pokoje}</p> <p>Cena: {offer.Cena} PLN</p> <div className='f-carousel has-thumbs is-ltr'> {offer.Galeria?.map((image, index) => ( <a key={index} data-fancybox="gallery" href={image.url} className={styles.carouselImage} > <img src={image.url} alt={image.altText || `Obraz ${index + 1}`} className="img-fluid rounded" /> </a> ))} </div> </div> </div> <Footer /> </div> ); 'use client'; import { useEffect } from 'react'; import { Fancybox } from '@fancyapps/ui'; import '@fancyapps/ui/dist/fancybox/fancybox.css'; const FancyboxGallery = () => { useEffect(() => { Fancybox.bind('[data-fancybox="gallery"]', { dragToClose: false, Toolbar: { display: { left: ['infobar'], middle: ['fullscreen'], right: ['thumbs', 'close'], }, }, Images: { zoom: false, }, Thumbs: { type: 'modern', }, Carousel: { transition: 'fade', // Płynne przejścia friction: 0, // Średni opór infinite: true, }, on: { 'Carousel.ready Carousel.change': (fancybox) => { fancybox.container.style.setProperty( '--bg-image', `url("${fancybox.getSlide().thumbSrc}")` ); }, }, }); // Cleanup Fancybox bindings when component is unmounted return () => { Fancybox.destroy(); }; }, []); }; export default FancyboxGallery; </code>
useEffect(() => {
    if (offer?.Galeria?.length) {
      const carouselElement = document.querySelector(".f-carousel");
      new Carousel(carouselElement, {
        Dots: true,
        Navigation: true,
      });

      Fancybox.bind("[data-fancybox='gallery']", {
        infinite: true,
      });
    }

    return () => {
      Fancybox.destroy();
      const carouselElement = document.querySelector(".f-carousel");
      if (carouselElement) {
        carouselElement.Carousel?.destroy();
      }
    };
  }, [offer]);

 return (
    <div>
      <Navbar />
      <div className="container-fluid">
        <div className="col-md-8 mx-auto">
          <h1>{offer.Tytul_oferty}</h1>
          <p>{opis}</p>
          <p>Powierzchnia: {offer.Powierzchnia} m²</p>
          <p>Pokoje: {offer.Pokoje}</p>
          <p>Cena: {offer.Cena} PLN</p>


          <div className='f-carousel has-thumbs is-ltr'>
            {offer.Galeria?.map((image, index) => (
              <a
                key={index}
                data-fancybox="gallery"
                href={image.url}
                className={styles.carouselImage}
              >
                <img
                  src={image.url}
                  alt={image.altText || `Obraz ${index + 1}`}
                  className="img-fluid rounded"
                />
              </a>
            ))}
          </div>
        </div>
      </div>
      <Footer />
    </div>
  );

'use client';

import { useEffect } from 'react';
import { Fancybox } from '@fancyapps/ui';
import '@fancyapps/ui/dist/fancybox/fancybox.css';

const FancyboxGallery = () => {
  useEffect(() => {
    Fancybox.bind('[data-fancybox="gallery"]', {
      dragToClose: false,

      Toolbar: {
        display: {
          left: ['infobar'],
          middle: ['fullscreen'],
          right: ['thumbs', 'close'],
        },
      },

      Images: {
        zoom: false,
      },

      Thumbs: {
        type: 'modern',
      },

      Carousel: {
        transition: 'fade', // Płynne przejścia
        friction: 0, // Średni opór
        infinite: true,
      },

      on: {
        'Carousel.ready Carousel.change': (fancybox) => {
          fancybox.container.style.setProperty(
            '--bg-image',
            `url("${fancybox.getSlide().thumbSrc}")`
          );
        },
      },
    });

    // Cleanup Fancybox bindings when component is unmounted
    return () => {
      Fancybox.destroy();
    };
  }, []);
};

export default FancyboxGallery;

I’m trying to create a gallery that fancyapps has on their page: https://fancyapps.com/carousel/. And it is a gallery “combine with fancybox”. I can’t get through this :c

New contributor

grabarzo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật