Skip to content

Commit

Permalink
1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
optimalisatie committed Feb 19, 2020
1 parent 098cef5 commit 6a7e6d6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 31 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.com/style-tools/lazy.svg?branch=master)](https://travis-ci.com/style-tools/lazy) [![Version](https://img.shields.io/github/release/style-tools/lazy.svg)](https://github.com/style-tools/lazy/releases) [![npm version](https://badge.fury.io/js/%40style.tools%2Flazy.svg)](http://badge.fury.io/js/%40style.tools%2Flazy) [![Latest Stable Version](https://poser.pugx.org/styletools/lazy/v/stable.png)](https://packagist.org/packages/styletools/lazy)

# Lazy Image and Iframe Loader
# Lazy Loader

A lightweight lazy loader based on [Intersection Observer V2](https://developers.google.com/web/updates/2019/02/intersectionobserver-v2) with a tiny fallback for old browsers.

Expand All @@ -10,7 +10,7 @@ A lightweight lazy loader based on [Intersection Observer V2](https://developers
- `.webp` rewrite with fallback (WebP support for `<img>` tag, saves a server-side redirect)
- `inview` and `out-of-view` callback (persistent observer for advanced element-in-view usage)
- `$lazybg` for lazy loading of `background-image` in stylesheets (CSS-variables)
- tiniest lazy load script `$z()` (300 bytes).
- tiniest lazy load script `$z()` (300 bytes)

#### Examples

Expand Down
8 changes: 4 additions & 4 deletions dist/lazy+data-attr+polyfill+events.js

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

10 changes: 5 additions & 5 deletions dist/lazy+webp+data-attr+polyfill+events.js

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

43 changes: 23 additions & 20 deletions src/lazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,30 +158,33 @@ function $lazy(config, inview, observer_callback) {
// event based fallback
if (CLICK_EXTENSION) {
for (var i = 0, l = assets.length; i < l; i++) {
asset = assets[i];
if (observer) {
observer.observe(asset);
} else {
// simple fallback if Intersection Observer is not available
observer_callback([asset]);
}
(function(asset) {

if (observer) {
observer.observe(asset);
} else {
// simple fallback if Intersection Observer is not available
observer_callback([asset]);
}

// event listener
var listener = function(e) {
// event listener
var listener = function(e) {

// remove event
asset.removeEventListener(e.type, listener);
// call handler
// remove event
asset.removeEventListener(e.type, listener);
// call handler

observer_callback([asset],asset);
};
observer_callback([asset],asset);
};

for (var _i = 0, _l = eventtypes.length; _i < _l; _i++) {
asset.addEventListener(eventtypes[_i], listener, {
"passive": true,
"once": true
});
}
})(assets[i]);

for (var _i = 0, _l = eventtypes.length; _i < _l; _i++) {
asset.addEventListener(eventtypes[_i], listener, {
"passive": true,
"once": true
});
}
}
} else {

Expand Down

0 comments on commit 6a7e6d6

Please sign in to comment.