featherlight icon indicating copy to clipboard operation
featherlight copied to clipboard

Fade-in images on gallery navigation

Open emmemeno opened this issue 7 years ago • 1 comments

Hello and thank you for featherlight! I'm using the gallery extension and it works like a charm except the fade-in effect on gallery navigation. The gallery itself fades in and out correctly, but singles images only fade-out, not fade-in. Do I miss something?

emmemeno avatar Nov 27 '17 09:11 emmemeno

Yes, this was a bit of an annoying issue. It happens because when the next image is added to the DOM its opacity is 1 and so jQuery fadeTo doesnt work because its already 100% visible. The solution would be to add this one line to the source code at line 145 of featherlight.gallery.js:

$newContent.fadeTo(0, 0);

but until that gets added to the codebase, this will serve as a work-around:

$('a.gallery').featherlightGallery({
     afterContent: function(event) {
          // make sure new image is actually hidden before it fades in
          $(this.$content).fadeTo(0, 0);
     },
     afterOpen: function(event) {
          // this function is necessary to prevent first image from being hidden
          $(this.$content).fadeTo(this.galleryFadeIn, 1);
     },
});

shamoon avatar Feb 23 '18 17:02 shamoon