dimsemenov/PhotoSwipe

V5 Beta: Option bgOpacity: 0, freezes the lightbox

acwolff opened this issue · 3 comments

If I use option bgOpacity: 0, I can open the lightbox once by clicking on a thumbnail, but if I close it next and tries to open it again by clicking on a thumbnail, the system is frozen.

I had this behaviour, also. It seems that the lightbox is not being fully destroyed when closed, so the check to make sure only one instance is running at a time then fails.

I added one line to photoswipe.esm.js, at line 4978.

close() {
    if (!this.opener.isOpen || this.isDestroying) {
      return;
    }
    this.isDestroying = true;
    this.dispatch('close');
    this.events.removeAll();
    this.opener.close();

    this.destroy(); // fully destroy the lightbox

}

Also, as the destroy may now be called twice, this helps keep it clean, at line 4691. I really should submit these as a pull request...

  destroy() {
    if(this._cachedItems != null) {
      this._cachedItems.forEach(content => content.destroy());
      this._cachedItems = null;
    }
  }

Thanks @david-raine
Your code works perfectly.

Solved in vs 5.2