themyth92 / ngx-lightbox

Lightbox2 use with angular >= 5
MIT License
115 stars 70 forks source link

Multiple lightboxes open if clickable image is under the first lightbox #49

Open jer-tx opened 4 years ago

jer-tx commented 4 years ago

Hard to explain what exactly is happening but, I have a bunch of images on a page (like a gallery), all set up to use lightbox. If you click on one, it opens the lightbox. If you click outside of the lightbox (to close it) and your mouse is over one of the other images, it'll not close the lightbox but instead open another one directly overtop. This is inconsistent though and doesn't always occur.

themyth92 commented 4 years ago

Lightbox can only be opened when u invoked it. E.g

this._lightbox.open(...)

You can look for more example here https://github.com/themyth92/ngx-lightbox#component

I think what you can do is to prevent open lightbox if one is already opened ? Like a flag or something. That way it can only close the lightbox when it is outside the opened modal and not open a new lightbox. E.g:

open(index: number): void {
    // open lightbox
   if (!this.lightboxOpened) {
      this._lightbox.open(this._albums, index);
   }
 }