compact / angular-bootstrap-lightbox

An AngularJS lightbox built using UI Bootstrap Modal.
http://compact.github.io/angular-bootstrap-lightbox/
MIT License
306 stars 134 forks source link

Troubles with loading image in FF (38.0.1) #32

Closed dvakor closed 9 years ago

dvakor commented 9 years ago

When i'm opening lightbox by clicking on any image on my page and image loaded and after this image's height\width becomes 0px. I'm try to debug this and found reason of that behavior: ImageLoader.load(src) promise generate both event success and failure... In the Chrome failure fire before success and we see no problems, but in FF success fire before failure and it resize to 0px.

OK, i'm deep more in this function and found intresting thing,

scope.$watch(function () { return attrs.lightboxSrc; }

fires two times,

1st time with attrs.lightboxSrc == "" and Lightbox.index == -1 2st time with attrs.lightboxSrc == %MyUrl% and Lightbox.index == %MyIndex%

I'm fix this by this code

if(Lightbox.index < 0){ return }

before

ImageLoader.load(src).then(function (image) {})

But i dont wanna to pull request cause i dont know how correct my code >.<

Sorry for my English, its not my native :)

Ryuno-Ki commented 9 years ago

Can you link to your fork, @ArchLord42RU? I ran into the same issue as well. Maybe we can figure out something together :)

dvakor commented 9 years ago

I found the main trouble: it is a trying to load empty image. I'm fixed it and its work fine now :)

Ryuno-Ki commented 9 years ago

Jay, that worked. Spotted a bug while applying your patch :)

maximebf commented 8 years ago

I have the same bug. This bug occurs when the image have already been loaded once. They are cached by the browser and the promise resolves instantly. The propose solution by @ArchLord42RU resolves this issue. It would be great to merge it. Thank you

fferrara commented 8 years ago

Same situation here. I lost some time before finding this solution. It works great, @ArchLord42RU ! +1 for merging it

jessemorton commented 8 years ago

@compact Can this fix be merged please, if it's satisfactory? I'm having the same issue reported by others.

compact commented 8 years ago

Fixed, please check v0.12.0.

Sorry for the wait.