Skip to content

Commit

Permalink
Releasing 17.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
verlok committed Apr 10, 2022
1 parent 15d392d commit 551125a
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 13 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.7.0

- Added the new option `restore_on_error` to restore original attributes on error.

#### 17.6.1

- Removed nasty "debugger" from code (sorry about that rookie mistake!)
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Please note that the video poster can be lazily loaded too.

## 👩‍💻 Getting started - Script

The latest, recommended version of LazyLoad is **17.6.1**.
The latest, recommended version of LazyLoad is **17.7.0**.

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

Expand All @@ -168,7 +168,7 @@ Quickly understand how to upgrade from a previous version reading the [practical
The easiest way to use LazyLoad is to include the script from a CDN:

```html
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.6.1/dist/lazyload.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.7.0/dist/lazyload.min.js"></script>
```

Then, in your javascript code:
Expand Down Expand Up @@ -209,7 +209,7 @@ Then include the script.
```html
<script
async
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.6.1/dist/lazyload.min.js"
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.7.0/dist/lazyload.min.js"
></script>
```

Expand Down Expand Up @@ -243,7 +243,7 @@ Then include the script.
```html
<script
async
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.6.1/dist/lazyload.min.js"
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.7.0/dist/lazyload.min.js"
></script>
```

Expand Down Expand Up @@ -600,6 +600,8 @@ The [demos](https://github.com/verlok/vanilla-lazyload/tree/master/demos) folder
| Loading | Asynchronous loading LazyLoad + InterserctionObserver with requireJS | [Code](demos/amd_polyfill.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/amd_polyfill.html) |
| Loading | Asynchronous loading LazyLoad with `<script async>` | [Code](demos/async.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/async.html) |
| Loading | Asynchronous loading multiple LazyLoad instances with `<script async>` | [Code](demos/async_multiple.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/async_multiple.html) |
| Error | Test error loading behaviour when `restore_on_error` is `false` | [Code](demos/error_no_restore.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/error_no_restore.html) |
| Error | Test error loading behaviour when `restore_on_error` is `true` | [Code](demos/error_restore.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/error_restore.html) |
| Technique | Fade in images as they load | [Code](demos/fade_in.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/fade_in.html) |
| Technique | Lazy load images in CSS-only horizontal sliders (Netflix style) | [Code](demos/sliders_css_only.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/sliders_css_only.html) |
| Technique | Lazily create Swiper instances and lazily load Swiper images | [Code](demos/swiper.html) | [Live](https://www.andreaverlicchi.eu/vanilla-lazyload/demos/swiper.html) |
Expand Down Expand Up @@ -709,6 +711,7 @@ Here's the list of the options.
| `callback_applied` | A callback function which is called whenever a multiple background element starts loading. Arguments: DOM element, lazyload instance. | `null` | `(el)=>{console.log("Applied", el)}` |
| `callback_finish` | A callback function which is called when there are no more elements to load _and_ all elements have been downloaded. Arguments: lazyload instance. | `null` | `()=>{console.log("Finish")}` |
| `use_native` | This boolean sets whether or not to use [native lazy loading](https://addyosmani.com/blog/lazy-loading/) to do [hybrid lazy loading](https://www.smashingmagazine.com/2019/05/hybrid-lazy-loading-progressive-migration-native/). On browsers that support it, LazyLoad will set the `loading="lazy"` attribute on images, iframes and videos, and delegate their loading to the browser. | `false` | `true` |
| `restore_on_error` | Tells LazyLoad if to restore the original values of `src`, `srcset` and `sizes` when a loading error occurs. | `false` | `true` |

### Methods

Expand Down
4 changes: 3 additions & 1 deletion dist/lazyload.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ define(function () { 'use strict';
callback_error: null,
callback_finish: null,
callback_cancel: null,
use_native: false
use_native: false,
restore_on_error: false
};
var getExtendedSettings = function getExtendedSettings(customSettings) {
return _extends({}, defaultSettings, customSettings);
Expand Down Expand Up @@ -497,6 +498,7 @@ define(function () { 'use strict';
addClass(element, settings.class_error);
setStatus(element, statusError);
safeCallback(settings.callback_error, element, instance);
if (settings.restore_on_error) restoreOriginalAttrs(element, attrsSrcSrcsetSizes);
if (!goingNative) checkFinish(settings, instance);
};
var addOneShotEventListeners = function addOneShotEventListeners(element, settings, instance) {
Expand Down
2 changes: 1 addition & 1 deletion dist/lazyload.amd.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/lazyload.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const defaultSettings = {
callback_error: null,
callback_finish: null,
callback_cancel: null,
use_native: false
use_native: false,
restore_on_error: false,
};

const getExtendedSettings = (customSettings) => {
Expand Down Expand Up @@ -461,6 +462,7 @@ const errorHandler = (event, element, settings, instance) => {
addClass(element, settings.class_error);
setStatus(element, statusError);
safeCallback(settings.callback_error, element, instance);
if (settings.restore_on_error) restoreOriginalAttrs(element, attrsSrcSrcsetSizes);
if (!goingNative) checkFinish(settings, instance);
};

Expand Down
Loading

0 comments on commit 551125a

Please sign in to comment.