jQuery Lazy horizontal data-src load fade or animate loading image dont work
$('.lazy').Lazy({
// your configuration goes here
scrollDirection: 'horizontal',
effect: 'fadeIn',
visibleOnly: true,
onError: function(element) {
console.log('error loading ' + element.data('data-src'));
}
});
example https://jsfiddle.net/ypcao1xx/
<div class="card-hor-image card-image lazy" data-src="https://www.gstatic.com/webp/gallery3/2.png">
Thanks for asking your question here. Please let me explain why your effect is not working as expected.
You had set the scroll direction to
horizontal
. But actually your example worksvertical
. So the plugin will check the wrong dimensions. Set the value tovertial
or just remove the config parameter, to let check all dimensions.You set the
effect
tofadeIn
but forgot to set aeffectTime
. So the default time would be zero, what is basically no seeable effect. So give it a propper time.By default, Lazy will listen on scroll events on the
window
object. But you are using a scroll container, defined by class.wrapper-scroll
. You need to tell this to the script, with theappendScroll
parameter.For effects the
threshold
should be set to zero, because otherwise the effect starts, before the user might see the element. It will work without too, but may be not visibile otherwise.Keeping this things in ming, we now have a working example: