gatsby-image
Advanced tools
Comparing version 1.0.3 to 1.0.4
19
index.js
@@ -90,12 +90,25 @@ "use strict"; | ||
// If this browser doesn't support the IntersectionObserver API | ||
// we just start downloading the image right away. | ||
// we default to start downloading the image right away. | ||
var _this = (0, _possibleConstructorReturn3.default)(this, _React$Component.call(this, props)); | ||
var isVisible = true; | ||
var imgLoaded = true; | ||
var IOSupported = false; | ||
if (typeof window !== "undefined" && window.IntersectionObserver) { | ||
isVisible = false; | ||
imgLoaded = false; | ||
IOSupported = true; | ||
} | ||
// Always don't render image while server rendering | ||
if (typeof window === "undefined") { | ||
isVisible = false; | ||
imgLoaded = false; | ||
} | ||
_this.state = { | ||
isVisible: isVisible | ||
isVisible: isVisible, | ||
imgLoaded: imgLoaded, | ||
IOSupported: IOSupported | ||
}; | ||
@@ -168,3 +181,3 @@ | ||
onLoad: function onLoad() { | ||
return _this3.setState({ imgLoaded: true }); | ||
return _this3.state.IOSupported && _this3.setState({ imgLoaded: true }); | ||
} | ||
@@ -171,0 +184,0 @@ }) |
{ | ||
"name": "gatsby-image", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Lazy-loading React image component with optional support for the blur-up effect.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
8682
206