@dylanvann/gatsby-image
Advanced tools
Comparing version 2.0.0-beta.4 to 2.0.0-beta.5
17
index.js
@@ -63,9 +63,9 @@ "use strict"; | ||
var ioListeners = {}; | ||
var ioListenerMap = {}; | ||
var listenToIntersections = function listenToIntersections(el, margin, cb) { | ||
if (typeof window !== "undefined") return; | ||
if (typeof window === "undefined") return; | ||
if (!window.IntersectionObserver) return; // Try to get the ioListener. | ||
var ioListener = ioListeners[margin]; | ||
var ioListener = ioListenerMap[margin]; | ||
@@ -75,3 +75,4 @@ if (!ioListener) { | ||
var listeners = []; | ||
var io = new window.IntersectionObserver(function (entries) { | ||
var callback = function callback(entries) { | ||
entries.forEach(function (entry) { | ||
@@ -85,3 +86,3 @@ listeners.forEach(function (_ref) { | ||
if (entry.isIntersecting || entry.intersectionRatio > 0) { | ||
ioListeners[margin].io.unobserve(el); | ||
ioListenerMap[margin].io.unobserve(el); | ||
cb(); | ||
@@ -92,3 +93,5 @@ } | ||
}); | ||
}, { | ||
}; | ||
var io = new window.IntersectionObserver(callback, { | ||
rootMargin: margin + "px" | ||
@@ -100,3 +103,3 @@ }); | ||
}; | ||
ioListeners[margin] = ioListener; | ||
ioListenerMap[margin] = ioListener; | ||
} | ||
@@ -103,0 +106,0 @@ |
{ | ||
"name": "@dylanvann/gatsby-image", | ||
"description": "Lazy-loading React image component with optional support for the blur-up effect.", | ||
"version": "2.0.0-beta.4", | ||
"version": "2.0.0-beta.5", | ||
"author": "Kyle Mathews <mathews.kyle@gmail.com>", | ||
@@ -6,0 +6,0 @@ "bugs": { |
29308
411