Skip to content

Commit 840032e

Browse files
author
aFarkas
committed
fix removeEventListener
1 parent b89238f commit 840032e

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ The recommended LQUIP pattern has the following advantages. The lquip-src is not
8989
**lazysizes** automatically detects new elements with the class ``lazyload`` so you won't need to call or configure anything in most situations.
9090

9191
####JS API - options
92-
Options can be set by declaring a global conifguration option object named ``lazySizesConfig``. This object should be defined before the including lazySizes script or at least in the same script file. Here a basic example:
92+
Options can be set by declaring a global configuration option object named ``lazySizesConfig``. This object should be defined before the including lazySizes script or at least in the same script file. Here a basic example:
9393

9494
```js
9595
window.lazySizesConfig = {
@@ -103,7 +103,7 @@ Here the list of options:
103103
* ``lazySizesConfig.lazyClass`` (default: ``"lazyload"``): Marker class for all elements which should be lazy loaded (There can be only one ``class``. In case you need to add some other element, without the defined class, simply add it per JS: ``$('.lazy-others').addClass('lazyload');``)
104104
* ``lazySizesConfig.preloadAfterLoad`` (default: ``false``): Wether lazysizes should load all elements after the window onload event. (Note: lazysizes will then load all elements using a queue. Only two parallel elements are loaded at the same time. This makes sure that other postboned downloads are also loaded.). Recommendation: On non-mobile devices this should be ``true``.
105105
* ``lazySizesConfig.beforeUnveil`` (default: ``undefined``): A callback function, which will be invoked for each lazyload element right before of the "unveil" transformation. Gets the ``element`` as first argument passed. In case the callback function returns ``false``, the default transformation action will be prevented.
106-
* ``lazySizesConfig.beforeSizes`` (default: ``undefined``): A callback function, which will be invoked for each element width the ``data-sizes="auto"`` attribute right before the calculated ``sizes`` attribute will be set. Gets the ``element`` and the calculated width for the sizes attribute passed. In case the callback function returns a number this number will be set, in case it returns ``false`` the ``sizes`` attribute won't be changed.
106+
* ``lazySizesConfig.beforeSizes`` (default: ``undefined``): A callback function, which will be invoked for each element with the ``data-sizes="auto"`` attribute right before the calculated ``sizes`` attribute will be set. Gets the ``element`` and the calculated width for the sizes attribute passed. In case the callback function returns a number this number will be set, in case it returns ``false`` the ``sizes`` attribute won't be changed.
107107
* ``lazySizesConfig.onlyLargerSizes`` (default: ``true``): In case a responsive image had the ``data-sizes="auto"`` attribute and the computed new size decreases, lazysizes won't normally change the ``sizes`` attribute to a lower value.
108108
* ``lazySizesConfig.srcAttr`` (default: ``"data-src"``): The attribute, which should be transformed to ``src``.
109109
* ``lazySizesConfig.srcset`` (default: ``"data-srcset"``): The attribute, which should be transformed to ``srcset``.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "lazysizes",
33
"repo": "afarkas/lazysizes",
4-
"version": "0.1.3",
4+
"version": "0.1.4",
55
"main": "lazysizes.min.js",
66
"scripts": [
77
"lazysizes.min.js"

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lazysizes",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"repo": "afarkas/lazysizes",
55
"main": "lazysizes.min.js",
66
"scripts": ["lazysizes.min.js"],

lazysizes.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
var setImmediate = window.setImmediate || window.setTimeout;
2626
var scriptUrls = {};
2727
var addRemoveImgEvents = function(dom, fn, add){
28-
var action = add ? 'addEventListener' : removeEventListener;
28+
var action = add ? 'addEventListener' : 'removeEventListener';
2929
dom[action]('load', fn, false);
3030
dom[action]('abort', fn, false);
3131
dom[action]('readystatechange', fn, false);
@@ -88,8 +88,9 @@
8888
clearTimeout(resetPreloadingTimer);
8989
if(e && e.target){
9090
addRemoveImgEvents(e.target, resetPreloading);
91-
} else {
92-
isPreloading--;
91+
}
92+
if(!e || isPreloading < 0 || !e.target) {
93+
isPreloading = 0;
9394
}
9495
};
9596
var lazyEvalLazy = (function(){

lazysizes.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lazysizes",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"engines": {
55
"node": ">= 0.8.0"
66
},

0 commit comments

Comments
 (0)