react-images icon indicating copy to clipboard operation
react-images copied to clipboard

closeOnBackdropClick doesn't work with custom View

Open TomPradat opened this issue 5 years ago • 3 comments

Hi, first of all thanks for this great lib :hugs:

So it's not explained in the docs that the closeOnBackdropClick needs the viewer's container and viewer's image to have some classes.

Without this knowledge, when using a custom View component, the closeOnBackdropClick doesn't work.

It would be great to explain this on the docs and provide those classes in the innerProps or so

TomPradat avatar Feb 17 '20 13:02 TomPradat

Hi Tom do you mind saying what classes are needed? Thanks

onadeem1 avatar Feb 29 '20 09:02 onadeem1

I believe you have to add the following class on your View's root element : react-images__view

TomPradat avatar Feb 29 '20 14:02 TomPradat

I believe you have to add the following class on your View's root element : react-images__view

This does not work with the following:

import React from 'react';
import Img from 'gatsby-image';
import Carousel, { ModalGateway, Modal } from 'react-images';

const GalleryImage = props => {
  return (
    <Img
      className="react-images__view"
      imgStyle={{
        objectFit: 'contain'
      }}
      fluid={props.data}
      alt={props.data.caption}
    />
  );
};

const MyComponent = props => {
  // ...

  return (
    <ModalGateway>
      {modalIsOpen && (
        <Modal onClose={() => setModalIsOpen(false)}>
          <Carousel views={images} components={{ View: GalleryImage }} />
        </Modal>
      )}
    </ModalGateway>
  );
};

chaddjohnson avatar Mar 06 '20 21:03 chaddjohnson