2

My client requested an image gallery feature. Such that I will have an array of images and on clicking each image, I will get like a modal that shows all the images available one by one. I want to achieve this with the Ionic Swiper Component. The example below is for Ionic-Angular, I need Ionic-React.

https://www.youtube.com/watch?v=BGoL0uWRTrY

Is there a way to open the image as a gallery and have zoom, prev and next swipe functionality?

<div className="mt-2">
              <IonSlides ref={slideRef} options={slideOpts}>
                {bridImages.map((image, idx) => (
                  <IonSlide key={idx} className="img-container">
                    <img
                      src={image.url}
                      alt={image.alt}
                    />
                  </IonSlide>
                ))}
              </IonSlides>
            </div>

Or if there's any other library that is mobile friendly and can also work with Ionic-React, please let me know.

halfer
  • 19,824
  • 17
  • 99
  • 186
AbdulAzeez Olanrewaju
  • 976
  • 1
  • 13
  • 32

1 Answers1

1
<IonSlides
  options={slideOpts}
  ref={mySlides}
  onIonSlideDidChange={handleSlideChange}
>

list with the event handler and get the swiper object which holds the activeIndex

const handleSlideChange = async () => {
  const swiper = await mySlides.current.getSwiper();
  console.log("Slide Index", swiper.activeIndex);
  // setDisablePrevBtn(swiper.isBeginning);
  // setDisableNextBtn(swiper.isEnd);
};
Aaron Saunders
  • 33,180
  • 5
  • 60
  • 80