Skip to content

Commit

Permalink
add proxy change event to extend bgset (fixes #532)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander.farkas committed Sep 10, 2018
1 parent 0c01e9d commit 871ccfa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion plugins/bgset/ls.bgset.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,16 @@
var elem = image._lazybgset;
var bg = image.currentSrc || image.src;


if(bg){
elem.style.backgroundImage = 'url(' + (regBgUrlEscape.test(bg) ? JSON.stringify(bg) : bg ) + ')';
var event = lazySizes.fire(elem, 'bgsetproxy', {
src: bg,
useSrc: regBgUrlEscape.test(bg) ? JSON.stringify(bg) : bg,
});

if(!event.defaultPrevented){
elem.style.backgroundImage = 'url(' + event.detail.useSrc + ')';
}
}

if(image._lazybgsetLoading){
Expand Down

0 comments on commit 871ccfa

Please sign in to comment.