-
Notifications
You must be signed in to change notification settings - Fork 344
Closed
Labels
Description
Hi,
When I use b-lazy to lazy load a background image set as data-src this works well. But my site is responsive so I am specifying data-src (default e.g. 320px or should that be the largest?), medium (770px) and large (> 771). When I re-size or re-orientate the device, the new image is not being used - only the one used first time is applied.
Also the data-src attributes are destroyed when b-lazy has finished applying.
My div:
<div class="b-lazy" src="placeholder.jpg"
data-src-medium="/images/600/Specifications.jpg')"
data-src-large="images/template/landingpage/features/980/Specifications.jpg">
</div>
My java script:
<script type="text/javascript">
jQuery(document).ready(function($j) {
var bLazy = new Blazy({
breakpoints: [
{
width: 770, // max-width
src: 'data-src-medium',
mode: 'viewport'
},
{
width: 99999, // max-width
src: 'data-src-large',
mode: 'viewport'
}],
selector: 'img,.b-lazy', // all images
offset: 200 // Loads images 200px before they're visible
});
});
</script>
I tried the following, but as of yet have been unable to get it to work:
var isIOS = /safari/g.test(navigator.userAgent.toLowerCase());
var ev = isIOS ? 'orientationchange' : 'resize';
var diff = (window.innerWidth-window.innerHeight);
$j(window).bind(ev,function(){
setTimeout(function(){
if(diff*((window.innerWidth-window.innerHeight)) < 0)
orientationChanged();
}, 500);
});
function orientationChanged() {
console.log("orientation changed");
$j('div.b-lazy').removeClass('b-loaded');
bLazy.revalidate();
}
Reactions are currently unavailable