Comparing version 1.0.5 to 1.0.6
@@ -1,2 +0,2 @@ | ||
/*! lozad.js - v1.0.5 - 2017-09-24 | ||
/*! lozad.js - v1.0.6 - 2017-09-25 | ||
* https://github.com/ApoorvSaxena/lozad.js | ||
@@ -24,2 +24,5 @@ * Copyright (c) 2017 Apoorv Saxena; Licensed MIT */ | ||
} | ||
if (element.dataset.backgroundImage) { | ||
element.style.backgroundImage = 'url(' + element.dataset.backgroundImage + ')'; | ||
} | ||
} | ||
@@ -26,0 +29,0 @@ }; |
@@ -1,4 +0,4 @@ | ||
/*! lozad.js - v1.0.5 - 2017-09-24 | ||
/*! lozad.js - v1.0.6 - 2017-09-25 | ||
* https://github.com/ApoorvSaxena/lozad.js | ||
* Copyright (c) 2017 Apoorv Saxena; Licensed MIT */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.lozad=e()}(this,function(){"use strict";function t(t){t.dataset.loaded=!0}var e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},r={rootMargin:"0px",threshold:0,load:function(t){t.dataset.src&&(t.src=t.dataset.src),t.dataset.srcset&&(t.srcset=t.dataset.srcset)}},o=function(t){return"true"===t.dataset.loaded},n=function(e){return function(r,o){r.forEach(function(r){r.intersectionRatio>0&&(o.unobserve(r.target),e(r.target),t(r.target))})}};return function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:".lozad",s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=e({},r,s),d=i.rootMargin,c=i.threshold,u=i.load,f=void 0;return window.IntersectionObserver&&(f=new IntersectionObserver(n(u),{rootMargin:d,threshold:c})),{observe:function(){for(var e=document.querySelectorAll(a),r=0;r<e.length;r++)o(e[r])||(f?f.observe(e[r]):(u(e[r]),t(e[r])))}}}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.lozad=e()}(this,function(){"use strict";function t(t){t.dataset.loaded=!0}var e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},r={rootMargin:"0px",threshold:0,load:function(t){t.dataset.src&&(t.src=t.dataset.src),t.dataset.srcset&&(t.srcset=t.dataset.srcset),t.dataset.backgroundImage&&(t.style.backgroundImage="url("+t.dataset.backgroundImage+")")}},o=function(t){return"true"===t.dataset.loaded},n=function(e){return function(r,o){r.forEach(function(r){r.intersectionRatio>0&&(o.unobserve(r.target),e(r.target),t(r.target))})}};return function(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:".lozad",s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},d=e({},r,s),c=d.rootMargin,i=d.threshold,u=d.load,f=void 0;return window.IntersectionObserver&&(f=new IntersectionObserver(n(u),{rootMargin:c,threshold:i})),{observe:function(){for(var e=document.querySelectorAll(a),r=0;r<e.length;r++)o(e[r])||(f?f.observe(e[r]):(u(e[r]),t(e[r])))}}}}); |
@@ -5,3 +5,3 @@ { | ||
"description": "A light-weight JS library to lazy load any HTML element such as images, ads, videos etc.", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"homepage": "https://github.com/ApoorvSaxena/lozad.js", | ||
@@ -8,0 +8,0 @@ "scripts": { |
@@ -12,3 +12,3 @@ # Lozad.js [](https://badge.fury.io/js/lozad) [](https://travis-ci.org/ApoorvSaxena/lozad.js) [](https://www.jsdelivr.com/package/npm/lozad) | ||
- allows lazy loading of dynamically added elements as well, | ||
- supports responsive images | ||
- supports responsive images and background images | ||
@@ -123,2 +123,11 @@ It is written with an aim to lazy load images, iframes, ads, videos or any other element using the recently added [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) with tremendous performance benefits. | ||
``` | ||
for use with background images | ||
```html | ||
<!-- background image example --> | ||
<div class="lozad" data-background-image="image.png"> | ||
</div> | ||
``` | ||
## Browser Support | ||
@@ -125,0 +134,0 @@ |
11896
82
152