Skip to content

Commit

Permalink
Merge branch 'hotfix/15.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Verlicchi committed Apr 1, 2020
2 parents d241a63 + 6d4cede commit 7ba6102
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 63 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Version 15

#### 15.1.1

Fixed a bug when loading lazy background images on HiDPI screens, `data-bg-hidpi` was mandatory, not it fallbacks to `data-bg`. #430

#### 15.1.0

Lazy background images just gained support for hiDPI ("retina") screens!
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Please note that the video poster can be lazily loaded too.

## 👩‍💻 Getting started - Script

The latest, recommended version of LazyLoad is **15.1.0**.
The latest, recommended version of LazyLoad is **15.1.1**.

Quickly understand how to upgrade from a previous version reading the [practical upgrade guide](UPGRADE.md).

Expand All @@ -160,14 +160,14 @@ If you prefer to load a polyfill, the regular LazyLoad behaviour is granted.
The easiest way to use LazyLoad is to include the script from a CDN:

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/lazyload.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/lazyload.min.js"></script>
```

Or, with the IntersectionObserver polyfill:

```html
<script src="https://cdn.jsdelivr.net/npm/[email protected]/intersection-observer.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/lazyload.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/lazyload.min.js"></script>
```

Then, in your javascript code:
Expand Down Expand Up @@ -200,7 +200,7 @@ Include RequireJS:
Then `require` the AMD version of LazyLoad, like this:

```js
var lazyLoadAmdUrl = "https://cdn.jsdelivr.net/npm/[email protected].0/dist/lazyload.amd.min.js";
var lazyLoadAmdUrl = "https://cdn.jsdelivr.net/npm/[email protected].1/dist/lazyload.amd.min.js";
var polyfillAmdUrl = "https://cdn.jsdelivr.net/npm/[email protected]/intersection-observer-amd.js";

/// Dynamically define the dependencies
Expand Down Expand Up @@ -246,7 +246,7 @@ Then include the script.
```html
<script
async
src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/lazyload.min.js"
src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/lazyload.min.js"
></script>
```
Expand Down Expand Up @@ -279,7 +279,7 @@ Then include the script.
```html
<script
async
src="https://cdn.jsdelivr.net/npm/[email protected].0/dist/lazyload.min.js"
src="https://cdn.jsdelivr.net/npm/[email protected].1/dist/lazyload.min.js"
></script>
```
Expand Down
18 changes: 3 additions & 15 deletions demos/background_images.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@
></a>
</li>
<li>
<a
href="#"
data-bg="https://via.placeholder.com/220x280?text=Img+02"
data-bg-hidpi="https://via.placeholder.com/440x560?text=Img+02"
></a>
<a href="#" data-bg="https://via.placeholder.com/220x280?text=Img+02"></a>
</li>
<li>
<a
Expand All @@ -54,11 +50,7 @@
></a>
</li>
<li>
<a
href="#"
data-bg="https://via.placeholder.com/220x280?text=Img+04"
data-bg-hidpi="https://via.placeholder.com/440x560?text=Img+04"
></a>
<a href="#" data-bg="https://via.placeholder.com/220x280?text=Img+04"></a>
</li>
<li>
<a
Expand All @@ -68,11 +60,7 @@
></a>
</li>
<li>
<a
href="#"
data-bg="https://via.placeholder.com/220x280?text=Img+06"
data-bg-hidpi="https://via.placeholder.com/440x560?text=Img+06"
></a>
<a href="#" data-bg="https://via.placeholder.com/220x280?text=Img+06"></a>
</li>
<li>
<a
Expand Down
8 changes: 2 additions & 6 deletions demos/background_images_multi.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<a
href="#/it/donna/open-toe_cod44740806jx.html"
data-bg-multi="url('https://via.placeholder.com/220x280?text=Img+02')"
data-bg-multi-hidpi="url('https://via.placeholder.com/440x560?text=Img+02')"
></a>
</li>
<li>
Expand All @@ -58,7 +57,6 @@
<a
href="#/it/donna/sneakers-tennis-shoes-basse_cod44738717am.html"
data-bg-multi="url('https://via.placeholder.com/220x280?text=Img+03')"
data-bg-multi-hidpi="url('https://via.placeholder.com/440x560?text=Img+03')"
></a>
</li>
<li>
Expand All @@ -72,7 +70,6 @@
<a
href="#/it/donna/sneakers-tennis-shoes-alte_cod44740860xg.html"
data-bg-multi="url('https://via.placeholder.com/220x280?text=Img+05+Left'),url('https://via.placeholder.com/440x560?text=Img+05+Right')"
data-bg-multi-hidpi="url('https://via.placeholder.com/440x560?text=Img+05+Left'),url('https://via.placeholder.com/440x560?text=Img+05+Right')"
class="multiple"
></a>
</li>
Expand Down Expand Up @@ -331,10 +328,9 @@
<script>
function logElementEvent(eventName, element) {
console.log(Date.now(), eventName, element.getAttribute("data-bg-multi"));
-hidpi}
}

var220x280ck_enter = function(element) {
callback_enter = function(element) {
var callback_enter = function(element) {
logElementEvent("🔑 ENTERED", element);
};
var callback_exit = function(element) {
Expand Down
14 changes: 9 additions & 5 deletions dist/lazyload.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,12 @@ define(function () { 'use strict';
safeCallback(settings.callback_reveal, element, instance); // <== DEPRECATED
};
var setBackground = function setBackground(element, settings, instance) {
var srcDataValue = getData(element, isHiDpi ? settings.data_bg_hidpi : settings.data_bg);
if (!srcDataValue) return;
element.style.backgroundImage = "url(\"".concat(srcDataValue, "\")");
getTempImage(element).setAttribute("src", srcDataValue); // Annotate and notify loading
var bg1xValue = getData(element, settings.data_bg);
var bgHiDpiValue = getData(element, settings.data_bg_hidpi);
var bgDataValue = isHiDpi && bgHiDpiValue ? bgHiDpiValue : bg1xValue;
if (!bgDataValue) return;
element.style.backgroundImage = "url(\"".concat(bgDataValue, "\")");
getTempImage(element).setAttribute("src", bgDataValue); // Annotate and notify loading

increaseLoadingCount(instance);
addClass(element, settings.class_loading);
Expand All @@ -272,7 +274,9 @@ define(function () { 'use strict';
// COULD BE A GRADIENT BACKGROUND IMAGE

var setMultiBackground = function setMultiBackground(element, settings, instance) {
var bgDataValue = getData(element, isHiDpi ? settings.data_bg_multi_hidpi : settings.data_bg_multi);
var bg1xValue = getData(element, settings.data_bg_multi);
var bgHiDpiValue = getData(element, settings.data_bg_multi_hidpi);
var bgDataValue = isHiDpi && bgHiDpiValue ? bgHiDpiValue : bg1xValue;
if (!bgDataValue) return;
element.style.backgroundImage = bgDataValue; // Annotate and notify applied

Expand Down
2 changes: 1 addition & 1 deletion dist/lazyload.amd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7ba6102

Please sign in to comment.