Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da91fc8

Browse files
committed
ver. 0.8.12
1 parent b2377cc commit da91fc8

26 files changed

+112
-116
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,8 @@ Note that any of Lazy Load XT `dist` files may be loaded from CDN, not only `jqu
802802
803803
## Version History
804804
805+
- [**0.8.12**](https://github.com/ressio/lazy-load-xt/tree/0.8.11) (12.01.2014): significant performance improvement,
806+
fix work in BlackBerry 5, fix `checkDuplicates` options
805807
- [**0.8.11**](https://github.com/ressio/lazy-load-xt/tree/0.8.11) (10.01.2014): fix to work in browsers without
806808
`scroll` event (e.g. Opera Mini), handle `touchmove` event for better response on mobile devices.
807809
- [**0.8.10**](https://github.com/ressio/lazy-load-xt/tree/0.8.10) (07.01.2014): bugfix "video" addon, remove loading of

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "lazyloadxt",
33
"description": "Lazy Load XT is mobile-oriented, fast and extensible jQuery plugin for lazy loading of images, videos and other media with built-in support of jQueryMobile framework. It improves performance of website by loading visible media elements only, and elements below the fold are loaded after page scroll. The plugin has many options, supports callbacks and special lazy events, that allows to have different loading effects (e.g. fade in and spinner effects). Examples of plugin and its addons include ajax, background images, infinite scroll, horizontal scroll, iframe-based widgets (YouTube, Vimeo, Google Maps Engine Lite, Facebook recommend button, Google+ profile), html5 video, responsive images with retina support (srcset and picture polyfills), social widgets (embedded tweet, Twitter share button, Google Plus badge and share button, Facebook like and recommend buttons, Facebook post comments), load all images before print, etc. Tested in IE 6-11, Chrome 1-31, Firefox 1.5-27.0, Safari 3-7, Opera 10.6-18.0, iOS 5-7, Android 2.3-4.4, and WP8. Requires jQuery 1.7+ or Zepto 1.0+.",
4-
"version": "0.8.11",
4+
"version": "0.8.12",
55
"main": ["dist/jquery.lazyloadxt.js", "dist/jquery.lazyloadxt.extra.js"],
66
"authors": ["RESS.io"],
77
"homepage": "http://ressio.github.io/lazy-load-xt",
88
"license": "MIT",
9-
"keywords": ["image", "images", "jquery", "jquerymobile", "lazy", "lazyload", "load", "media", "mobile", "performance", "responsive", "speed", "video", "vimeo", "youtube"],
9+
"keywords": ["effect", "image", "images", "jquery", "jquerymobile", "lazy", "lazyload", "load", "media", "mobile", "performance", "responsive", "speed", "video", "vimeo", "youtube"],
1010
"dependencies": {
1111
"jquery": ">=1.7.0"
1212
},

dist/jquery.lazyloadxt.autoload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Lazy Load XT v0.8.11 2014-01-10
1+
/*! Lazy Load XT v0.8.12 2014-01-12
22
* http://ressio.github.io/lazy-load-xt
33
* (C) 2014 RESS.io
44
* Licensed under MIT */

dist/jquery.lazyloadxt.autoload.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.lazyloadxt.bg.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Lazy Load XT v0.8.11 2014-01-10
1+
/*! Lazy Load XT v0.8.12 2014-01-12
22
* http://ressio.github.io/lazy-load-xt
33
* (C) 2014 RESS.io
44
* Licensed under MIT */

dist/jquery.lazyloadxt.bg.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.lazyloadxt.extra.js

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! Lazy Load XT v0.8.11 2014-01-10
1+
/*! Lazy Load XT v0.8.12 2014-01-12
22
* http://ressio.github.io/lazy-load-xt
33
* (C) 2014 RESS.io
44
* Licensed under MIT */
@@ -25,15 +25,14 @@
2525
edgeY: 0,
2626
visibleOnly: true
2727
},
28-
// autoload all images in Opera Mini and some mobile browsers without scroll event
29-
autoLoad = (window.onscroll === undefined || !!window.operamini),
3028
$window = $(window),
29+
$isFunction = $.isFunction,
30+
docElement = document.documentElement,
31+
// autoload all images in Opera Mini and some mobile browsers without scroll event or getBoundingClientRect()
32+
autoLoad = (window.onscroll === undefined || !!window.operamini || !docElement.getBoundingClientRect),
3133
dataLazied = 'lazied',
34+
load_error = 'load error',
3235
elements = [],
33-
viewportTop,
34-
viewportBottom,
35-
viewportLeft,
36-
viewportRight,
3736
$data = $.data || function (el, name) {
3837
return $(el).data(name);
3938
},
@@ -47,6 +46,17 @@
4746

4847
$.lazyLoadXT = $.extend(options, elementOptions, $.lazyLoadXT);
4948

49+
/**
50+
* Return def if value is undefined, otherwise return value
51+
* @param {*} value
52+
* @param {*} def
53+
* @returns *
54+
*/
55+
function getOrDef(value, def) {
56+
return value === undefined ? def : value;
57+
}
58+
59+
5060
/**
5161
* Add new elements to lazy-load list:
5262
* $(elements).lazyLoadXT() or $(window).lazyLoadXT()
@@ -57,13 +67,13 @@
5767
overrides = overrides || {};
5868

5969
var elementOptionsOverrides = {},
60-
blankImage = overrides.blankImage || options.blankImage,
61-
classNojs = overrides.classNojs || options.classNojs,
62-
checkDuplicates = overrides.checkDuplicates || true,
70+
blankImage = getOrDef(overrides.blankImage, options.blankImage),
71+
classNojs = getOrDef(overrides.classNojs, options.classNojs),
72+
checkDuplicates = getOrDef(overrides.checkDuplicates, true),
6373
prop;
6474

6575
for (prop in elementOptions) {
66-
elementOptionsOverrides[prop] = (overrides[prop] === undefined) ? options[prop] : overrides[prop];
76+
elementOptionsOverrides[prop] = getOrDef(overrides[prop], options[prop]);
6777
}
6878

6979
return this.each(function () {
@@ -81,8 +91,8 @@
8191
.data(dataLazied, 1)
8292
.removeClass(classNojs);
8393

84-
if (blankImage && $el[0].tagName === 'IMG' && !$el.attr('src')) {
85-
$el.attr('src', blankImage);
94+
if (blankImage && $el[0].tagName === 'IMG' && !this.src) {
95+
this.src = blankImage;
8696
}
8797

8898
// clone elementOptionsOverrides object
@@ -96,18 +106,6 @@
96106
};
97107

98108

99-
/**
100-
* Save visible viewport boundary to viewportXXX variables
101-
*/
102-
function calcViewport() {
103-
viewportTop = $window.scrollTop();
104-
viewportBottom = viewportTop + (window.innerHeight || $window.height());
105-
106-
viewportLeft = window.pageXOffset || 0;
107-
viewportRight = viewportLeft + (window.innerWidth || $window.width());
108-
}
109-
110-
111109
/**
112110
* Process function/object event handler
113111
* @param {string} event suffix
@@ -118,7 +116,7 @@
118116

119117
var handler = options['on' + event];
120118
if (handler) {
121-
if ($.isFunction(handler)) {
119+
if ($isFunction(handler)) {
122120
handler.call($el[0]);
123121
} else {
124122
$el
@@ -137,7 +135,7 @@
137135
* @param {Event} e
138136
*/
139137
function triggerLoadOrError(e) {
140-
triggerEvent(e.type, $(this).off('load error', triggerLoadOrError));
138+
triggerEvent(e.type, $(this).off(load_error, triggerLoadOrError));
141139
}
142140

143141

@@ -153,36 +151,36 @@
153151
force = force || autoLoad;
154152

155153
topLazy = Infinity;
156-
calcViewport();
157154

158-
for (var i = elements.length - 1; i >= 0; i--) {
155+
var viewportTop = $window.scrollTop(),
156+
viewportHeight = window.innerHeight || $window.height(),
157+
viewportWidth = window.innerWidth || $window.width(),
158+
i;
159+
160+
for (i = elements.length - 1; i >= 0; i--) {
159161
var $el = elements[i],
160162
el = $el[0],
161163
objData = $el.lazyLoadXT;
162164

163165
// remove items that are not in DOM
164-
if (!$.contains(document.documentElement, el)) {
166+
if (!$.contains(docElement, el)) {
165167
elements.splice(i, 1);
166168
} else if (force || !objData.visibleOnly || el.offsetWidth > 0 || el.offsetHeight > 0) {
167-
var offset = $el.offset(),
168-
elTop = offset.top,
169-
elLeft = offset.left,
169+
var elPos = el.getBoundingClientRect(),
170170
edgeX = objData.edgeX,
171171
edgeY = objData.edgeY,
172-
topEdge = elTop - edgeY;
172+
topEdge = (elPos.top + viewportTop - edgeY) - viewportHeight;
173173

174-
if (force ||
175-
((topEdge <= viewportBottom) && (elTop + $el.height() > viewportTop - edgeY) &&
176-
(elLeft <= viewportRight + edgeX) && (elLeft + $el.width() > viewportLeft - edgeX))) {
174+
if (force || (topEdge <= viewportTop && elPos.bottom > -edgeY &&
175+
elPos.left <= viewportWidth + edgeX && elPos.right > -edgeX)) {
177176

178177
triggerEvent('show', $el);
179178

180179
var srcAttr = objData.srcAttr,
181-
src = $.isFunction(srcAttr) ? srcAttr($el) : $el.attr(srcAttr);
180+
src = $isFunction(srcAttr) ? srcAttr($el) : el.getAttribute(srcAttr);
182181
if (src) {
183-
$el
184-
.on('load error', triggerLoadOrError)
185-
.attr('src', src);
182+
$el.on(load_error, triggerLoadOrError);
183+
el.src = src;
186184
}
187185

188186
elements.splice(i, 1);
@@ -225,8 +223,7 @@
225223

226224
// fast check for scroll event without new visible elements
227225
if (e && e.type === 'scroll') {
228-
calcViewport();
229-
if (topLazy >= viewportBottom) {
226+
if (topLazy >= $window.scrollTop()) {
230227
return;
231228
}
232229
}

dist/jquery.lazyloadxt.extra.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.

0 commit comments

Comments
 (0)