image-loader-spinner
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -27,2 +27,3 @@ "use strict"; | ||
var imageErrorSrc = null; | ||
var firstInit = true; | ||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; | ||
@@ -60,2 +61,3 @@ var observer = new MutationObserver((mutations) => { | ||
e.target.src = imageErrorSrc; | ||
imageErrorSrc = e.target.src; | ||
} | ||
@@ -81,4 +83,15 @@ function checkImages() { | ||
image.addEventListener("error", imageError); | ||
if (firstInit && isLocalImage(image.src)) | ||
image.src = image.src; | ||
}); | ||
if (firstInit) | ||
firstInit = false; | ||
} | ||
function isLocalImage(src) { | ||
if (src.startsWith(`http://${window.location.hostname}/`) || src.startsWith(`https://${window.location.hostname}/`)) | ||
return true; | ||
if (src.startsWith("http://") || src.startsWith("https://")) | ||
return false; | ||
return true; | ||
} | ||
function ImageLoader(errorUrl = null) { | ||
@@ -85,0 +98,0 @@ imageErrorSrc = errorUrl; |
{ | ||
"name": "image-loader-spinner", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Use a spinner until your images are completely loaded in the DOM", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
20036
186