Skip to content

Commit

Permalink
make intersectionobserver version compatible with plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander.farkas committed Oct 5, 2018
1 parent 367f462 commit 2f1a025
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/lazysizes-intersection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/*jshint eqnull:true */
if(!window.IntersectionObserver || !document.getElementsByClassName || !window.MutationObserver){return;}

var lazySizesConfig;
var lazysizes, lazySizesConfig;

var docElem = document.documentElement;

Expand All @@ -28,7 +28,7 @@

var requestAnimationFrame = window.requestAnimationFrame || setTimeout;

var requestIdleCallback = window.requestIdleCallback;
var requestIdleCallback = window.requestIdleCallback || setTimeout;

var regPicture = /^picture$/i;

Expand Down Expand Up @@ -61,7 +61,13 @@
var triggerEvent = function(elem, name, detail, noBubbles, noCancelable){
var event = document.createEvent('CustomEvent');

event.initCustomEvent(name, !noBubbles, !noCancelable, detail || {});
if(!detail){
detail = {};
}

detail.instance = lazysizes;

event.initCustomEvent(name, !noBubbles, !noCancelable, detail);

elem.dispatchEvent(event);
return event;
Expand Down Expand Up @@ -524,7 +530,7 @@
});
})();

return {
lazysizes = {
cfg: lazySizesConfig,
autoSizer: autoSizer,
loader: loader,
Expand All @@ -537,4 +543,6 @@
gW: getWidth,
rAF: rAF,
};

return lazysizes;
}));

0 comments on commit 2f1a025

Please sign in to comment.