From 0cbc6775502e86ca089fbbd2b5573371586fb3d8 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 18 Feb 2016 13:42:37 +0000 Subject: [PATCH 1/5] Test if unveiling img tag or changing background-image Changes data-src to src for IMG. Changes data-src to background-image:url() --- jquery.unveil.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jquery.unveil.js b/jquery.unveil.js index 8cfeb25..d375459 100644 --- a/jquery.unveil.js +++ b/jquery.unveil.js @@ -23,8 +23,12 @@ var source = this.getAttribute(attrib); source = source || this.getAttribute("data-src"); if (source) { - this.setAttribute("src", source); - if (typeof callback === "function") callback.call(this); + if (this.tagName === 'IMG') { + this.setAttribute("src", source); + } else { + this.style.backgroundImage = 'url('+source+')'; + } + if (typeof callback === "function") { callback.call(this); } } }); From e81817e69b4b8507368f9fbe0aa5e3c03bb08883 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 18 Feb 2016 14:57:58 +0000 Subject: [PATCH 2/5] Demo for changing background-image --- index.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index.html b/index.html index 0adb338..de920f8 100644 --- a/index.html +++ b/index.html @@ -165,6 +165,8 @@

Demo

If you're on a "normal" display, unveil will load the low resolution version (800x500). In case you're on a device with a retina display, the high resolution version (1280x800 in this case) will be loaded instead.

Scroll down to see it working - placeholder images from lorempixel.

+

Unveil to src on IMG tags

+ + +

Unveil to style="background-image:url()" on other tags

+ +
+
+
+
+
+
+
+
+
+
+

Browser support

Compatible with All Browsers and IE7+.

From 5655f22f5768a75b0f0883a7d1fa966036252e6c Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 21 Feb 2016 16:56:21 +0000 Subject: [PATCH 3/5] Update bower.json --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index a2a18ca..168b863 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "name": "jquery-unveil", - "version": "1.3.0", + "name": "jquery-unvei-mod", + "version": "1.3.1", "main": ["jquery.unveil.js"] } From 832d687f499451d60e6dac681e63bb506c517752 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 21 Feb 2016 17:05:47 +0000 Subject: [PATCH 4/5] Update bower.json --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 168b863..b013304 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "name": "jquery-unvei-mod", + "name": "jquery-unvei", "version": "1.3.1", "main": ["jquery.unveil.js"] } From 8f463796f49c1c43d23d8cb08549fa8ce7493596 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 21 Feb 2016 17:06:14 +0000 Subject: [PATCH 5/5] Update bower.json --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index b013304..ecf60aa 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "name": "jquery-unvei", + "name": "jquery-unveil", "version": "1.3.1", "main": ["jquery.unveil.js"] }