Skip to content

Commit

Permalink
Merge branch 'hotfix/7.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
verlok committed Apr 26, 2017
2 parents ecf66bd + 0173b36 commit 6028de5
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
1 change: 0 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module.exports = function (grunt) {
},
dist: {
files: {
"dist/lazyload.min.js": "dist/lazyload.js",
"dist/lazyload.transpiled.min.js": "dist/lazyload.transpiled.js",
}
}
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ Here's the list of the options.
| `elements_selector` | The selector of the image elements inside the container, as descendants of the element in the `container` option | `"img"` |
| `threshold` | The distance out of the viewport, expressed in pixel, before which to start loading the images | `300` |
| `throttle` | The time that has to pass between one element parsing and the following, when fast scroll events occur | `150` |
| `data_src` | The name of the dataset property containing the original image source. | `"original"` |
| `data_srcset` | The name of the dataset property containing the original image source set. If you also use the `sizes` attribute, put it directly in the `img` tag, as [`sizes` gets ignored when the `srcset` attribute is missing](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img). | `"original-set"` |
| `data_src` | The name of the dataset property containing the original image source. See [dataset naming note](#dataset-naming-note) below. | `"original"` |
| `data_srcset` | The name of the dataset property containing the original image source set in either `img` and `source` tags. See [dataset naming note](#dataset-naming-note) below. | `"originalSet"` |
| `class_loading` | The class applied to the elements while the loading is in progress. | `"loading"` |
| `class_loaded` | The class applied to the elements when the loading is complete | `"loaded"` |
| `class_error` | The class applied to the elements when the element causes an error | `"error"` |
Expand All @@ -370,6 +370,12 @@ Here's the list of the options.
| `callback_set` | A function to be called when the src of an image is set in the DOM. | `null` |
| `callback_processed` | A function to be called when an image was processed. | `null` |

#### Dataset naming note

Please note that dataset properties of hyphenated data attributes (like `data-my-custom-attribute`) are automatically [converted to camel case](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset) by Javascript (so `myCustomAttribute`).

[Demo here](https://codepen.io/verlok/pen/LybvYy?editors=1011))


### Methods

Expand Down
2 changes: 1 addition & 1 deletion dist/lazyload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
threshold: 300,
throttle: 150,
data_src: "original",
data_srcset: "original-set",
data_srcset: "originalSet",
class_loading: "loading",
class_loaded: "loaded",
class_error: "error",
Expand Down
1 change: 0 additions & 1 deletion dist/lazyload.min.js

This file was deleted.

42 changes: 19 additions & 23 deletions dist/lazyload.transpiled.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
threshold: 300,
throttle: 150,
data_src: "original",
data_srcset: "original-set",
data_srcset: "originalSet",
class_loading: "loading",
class_loaded: "loaded",
class_error: "error",
Expand Down Expand Up @@ -271,32 +271,28 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
*/

handleScroll: function handleScroll() {
var _this = this;

var throttle = this._settings.throttle;

if (throttle !== 0) {
(function () {
var getTime = function getTime() {
new Date().getTime();
};
var now = getTime();
var remainingTime = throttle - (now - _this._previousLoopTime);
if (remainingTime <= 0 || remainingTime > throttle) {
if (_this._loopTimeout) {
clearTimeout(_this._loopTimeout);
_this._loopTimeout = null;
}
_this._previousLoopTime = now;
_this._loopThroughElements();
} else if (!_this._loopTimeout) {
_this._loopTimeout = setTimeout(function () {
this._previousLoopTime = getTime();
this._loopTimeout = null;
this._loopThroughElements();
}.bind(_this), remainingTime);
var getTime = function getTime() {
new Date().getTime();
};
var now = getTime();
var remainingTime = throttle - (now - this._previousLoopTime);
if (remainingTime <= 0 || remainingTime > throttle) {
if (this._loopTimeout) {
clearTimeout(this._loopTimeout);
this._loopTimeout = null;
}
})();
this._previousLoopTime = now;
this._loopThroughElements();
} else if (!this._loopTimeout) {
this._loopTimeout = setTimeout(function () {
this._previousLoopTime = getTime();
this._loopTimeout = null;
this._loopThroughElements();
}.bind(this), remainingTime);
}
} else {
this._loopThroughElements();
}
Expand Down
Loading

0 comments on commit 6028de5

Please sign in to comment.