Skip to content

Commit

Permalink
Releasing 17.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Verlicchi committed Jun 25, 2020
1 parent 8f01a30 commit b6f2448
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 33 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 17

#### 17.0.1

- Bug fix: `callback_exit()` was not being called on non-image elements (#468).

#### 17.0.0

- The `elements_selector` option now defaults to `.lazy` (was `img`)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Please note that the video poster can be lazily loaded too.

## 👩‍💻 Getting started - Script

The latest, recommended version of LazyLoad is **17.0.0**.
The latest, recommended version of LazyLoad is **17.0.1**.

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

Expand All @@ -196,14 +196,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 @@ -235,7 +235,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 @@ -280,7 +280,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 @@ -314,7 +314,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
13 changes: 8 additions & 5 deletions dist/lazyload.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ define(function () { 'use strict';
var statusLoading = "loading";
var statusLoaded = "loaded";
var statusApplied = "applied";
var statusEntered = "entered";
var statusError = "error";
var statusNative = "native";

Expand Down Expand Up @@ -143,8 +144,9 @@ define(function () { 'use strict';
var hasStatusNative = function hasStatusNative(element) {
return getStatus(element) === statusNative;
};
var statusesAfterLoading = [statusLoading, statusLoaded, statusApplied, statusError];
var hadStartedLoading = function hadStartedLoading(element) {
return !hasEmptyStatus(element);
return statusesAfterLoading.indexOf(getStatus(element)) >= 0;
};

var safeCallback = function safeCallback(callback, arg1, arg2, arg3) {
Expand Down Expand Up @@ -201,7 +203,7 @@ define(function () { 'use strict';
var resetObserver = function resetObserver(observer) {
observer.disconnect();
};
var unobserveIfRequired = function unobserveIfRequired(element, settings, instance) {
var unobserveEntered = function unobserveEntered(element, settings, instance) {
if (settings.unobserve_entered) unobserve(element, instance);
};

Expand Down Expand Up @@ -538,7 +540,7 @@ define(function () { 'use strict';
setStatus(element, statusNative);
};

var cancelLoadingIfRequired = function cancelLoadingIfRequired(element, entry, settings, instance) {
var cancelLoading = function cancelLoading(element, entry, settings, instance) {
if (!settings.cancel_on_exit) return;
if (!hasStatusLoading(element)) return;
if (element.tagName !== "IMG") return; //Works only on images
Expand All @@ -553,16 +555,17 @@ define(function () { 'use strict';
};

var onEnter = function onEnter(element, entry, settings, instance) {
setStatus(element, statusEntered);
unobserveEntered(element, settings, instance);
safeCallback(settings.callback_enter, element, entry, instance);
unobserveIfRequired(element, settings, instance);
if (hadStartedLoading(element)) return; //Prevent loading it again

load(element, settings, instance);
};
var onExit = function onExit(element, entry, settings, instance) {
if (hasEmptyStatus(element)) return; //Ignore the first pass, at landing

cancelLoadingIfRequired(element, entry, settings, instance);
cancelLoading(element, entry, settings, instance);
safeCallback(settings.callback_exit, element, entry, instance);
};

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 b6f2448

Please sign in to comment.