Kris-B / nanoGALLERY

image gallery simplified - jQuery plugin. Touch enabled, responsive, justified/cascading/grid layout and it supports pulling in Flickr, Google Photos and self hosted images.
https://nanogallery2.nanostudio.org/
439 stars 101 forks source link

Images sometimes fail to load after upon folder navigation in Safari #117

Closed mmcev106 closed 8 years ago

mmcev106 commented 8 years ago

I am able to reproduce this almost every time in Safari on both a Macbook and and iPad Air by doing the following:

  1. In Safari, go to http://audrydealmcever.com?broken-in-safari
  2. Open the first album (titled "Functional Pottery").
  3. Open the first child album (titled "Vases and Bottles"). The album will fail to display.

I have already done some troubleshooting. It appears that image elements created for images that already exist in the resource cache (both isChecked and isConfirmed are true) have a naturalWidth and naturalHeight of "0" for a split second before their elements are fully initialized (img.complete is still false). If nanoGALLERY happens to call thumbSetImgHeight() during this time, both dimensions get set to "0", and the gallery does not render properly. I was able to work around the issue by adding the following lines after the "var resource..." line in the LoadingImage.prototype.check() method:

if(!this.img.complete){
    resource.isConfirmed = false
    resource.isChecked = false
}

I'm hesitant to create a pull request since you might have a better long term fix in mind. If you have a better idea, I don't mind implementing it. Let me know if I can help further.

I should mention that I have also seen this happen a few times in Chrome while troubleshooting, but it is very rare (perhaps 1/100 refreshes).

Kris-B commented 8 years ago

I'll check this issue, but I'll need a little time as I don't have a macboock or a ipad...

Did you write a plugin for WP?

mmcev106 commented 8 years ago

My hack seems to work for now, so take your time. If you have any ideas on how to fix the problem, I wouldn't mind implementing and/or testing them.

I just threw together a very basic plugin for my wife's site. I've thought about creating a more polished version that could be published on wordpress.org.

Mark

On Mon, May 9, 2016 at 4:30 PM, Christophe Brisbois < notifications@github.com> wrote:

I'll check this issue, but I'll need a little time as I don't have a macboock or a ipad...

Did you write a plugin for WP?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/Kris-B/nanoGALLERY/issues/117#issuecomment-217995981

Kris-B commented 8 years ago

can you please check this page: http://nanogallery.brisbois.fr/testsafari2.html

mmcev106 commented 8 years ago

Tested in Safari on Desktop and iPad, on both your test link and the original site (after updating). It seems to work great now. Thanks very much!

Kris-B commented 8 years ago

thanks for your feedback!

New version just released: https://github.com/Kris-B/nanoGALLERY/releases/tag/v5.10.1