Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closeOnBackdropClick doesn't work with custom View #350

Open
TomPradat opened this issue Feb 17, 2020 · 3 comments
Open

closeOnBackdropClick doesn't work with custom View #350

TomPradat opened this issue Feb 17, 2020 · 3 comments

Comments

@TomPradat
Copy link

Hi, first of all thanks for this great lib 🤗

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

@onadeem1
Copy link

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

@TomPradat
Copy link
Author

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

@chaddjohnson
Copy link

chaddjohnson commented Mar 6, 2020

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>
  );
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants