From be974515518bea1b2995db53c3ff7c40de272396 Mon Sep 17 00:00:00 2001 From: Eisbehr Date: Tue, 17 Nov 2015 12:04:15 +0100 Subject: [PATCH] 0.6.4 - fixed bug on older iPads (thx to @Canu667) - fixed bug on IE triggering error callback before starts loading - let 'destroy' return 'undefined' to possible redefine own variables - removed some spacing on line endings --- README.md | 4 ++-- bower.json | 2 +- jquery.lazy.js | 23 ++++++++++------------- jquery.lazy.min.js | 4 ++-- package.json | 2 +- 5 files changed, 16 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 351888c..ab8f97f 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,10 @@ First of all, you will need a copy of [jQuery](http://jquery.com) to use Lazy su Lazy is available over [cdnjs](http://cdnjs.com) and [jsDelivr](http://jsdelivr.com) CDN and can directly included to every page. ```HTML - + - + ``` #### Self-Hosted diff --git a/bower.json b/bower.json index a090d3a..fcae530 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "jquery-lazy", "description": "Lazy is a fast, feature-rich and lightweight delayed content loading plugin for jQuery. It's designed to speed up page loading times and decrease traffic to your users by only loading the content in view. You can use Lazy in all vertical and horizontal scroll ways. It supports images in 'img' tags and backgrounds, supplied with css like 'background-image', by default or any other content by custom loaders. On images Lazy can set an default image or a placeholder while loading and supports retina displays as well.", - "version": "0.6.3", + "version": "0.6.4", "main": "jquery.lazy.min.js", "license": [ "MIT", diff --git a/jquery.lazy.js b/jquery.lazy.js index 3f3338a..08c1be1 100644 --- a/jquery.lazy.js +++ b/jquery.lazy.js @@ -1,5 +1,5 @@ /*! - * jQuery Lazy - v0.6.3 + * jQuery Lazy - v0.6.4 * http://jquery.eisbehr.de/lazy/ * * Copyright 2012 - 2015, Daniel 'Eisbehr' Kern @@ -132,13 +132,6 @@ // append plugin instance to all elements .data("plugin_" + instance.name, instance); - // bind error callback to items if set - if( configuration("onError") ) - items.on("error." + instance.name, function() - { - _triggerCallback("onError", $(this)); - }); - // set default image and/or placeholder to elements if configured if( configuration("defaultImage") || configuration("placeholder") ) for( var i = 0; i < items.length; i++ ) @@ -195,11 +188,11 @@ customLoader; // is not already handled - if( !element.data(configuration("handledName")) && + if( !element.data(configuration("handledName")) && // and is visible or visibility doesn't matter (!configuration("visibleOnly") || element.is(":visible")) && ( // and image source attribute is available - attribute && ( + attribute && ( // and is image tag where attribute is not equal source (tag == "img" && imageBase + attribute != element.attr("src")) || // or is non image tag where attribute is not equal background @@ -218,7 +211,7 @@ })(items[i]); // when something was loaded remove them from remaining items - if( loadTriggered ) + if( loadTriggered ) items = $(items).filter(function() { return !$(this).data(configuration("handledName")); @@ -420,7 +413,9 @@ { if( (callback = configuration(callback)) ) { - callback.apply(instance, Array.prototype.slice.call(arguments, 1)); + // jQuery's internal '$(arguments).slice(1)' are causing problems at least on old iPads + // below is shorthand of 'Array.prototype.slice.call(arguments, 1)' + callback.apply(instance, [].slice.call(arguments, 1)); return true; } @@ -554,7 +549,7 @@ * destroy this plugin instance * @access public * @type {function} - * @return void + * @return undefined */ _instance.destroy = function () { @@ -564,6 +559,8 @@ // clear events _events = {}; + + return undefined; }; // start using lazy and return all elements to be chainable or instance for further use diff --git a/jquery.lazy.min.js b/jquery.lazy.min.js index b8a2805..ac504e3 100644 --- a/jquery.lazy.min.js +++ b/jquery.lazy.min.js @@ -1,2 +1,2 @@ -/*! jQuery Lazy 0.6.3 - MIT & GPL-2.0 license - Copyright 2012-2015 Daniel 'Eisbehr' Kern */ -!function(t,e,r,n){"use strict";function a(r,n,a,o){function i(){p=e.devicePixelRatio>1,l(a),n("delay")>=0&&setTimeout(function(){u(!0)},n("delay")),(n("delay")<0||n("combined"))&&(o.e=m(n("throttle"),function(t){"resize"===t.type&&(b=v=-1),u(t.all)}),o.a=function(t){l(t),a.push.apply(a,t)},o.g=function(){return a},u(),t(n("appendScroll")).on("scroll."+r.name+" resize."+r.name,o.e))}function l(e){if(e=t(e).filter(function(){return!t(this).data(n("handledName"))&&(t(this).attr(n("attribute"))||t(this).attr(n("loaderAttribute")))}).data("plugin_"+r.name,r),n("onError")&&e.on("error."+r.name,function(){g("onError",t(this))}),n("defaultImage")||n("placeholder"))for(var a=0;ae.top&&-ae.left&&-a=0?b:b=t(e).width()}function s(){return v>=0?v:v=t(e).height()}function m(t,e){var a,o=0;return function(i,l){function u(){o=+new Date,e.call(r,i)}var c=+new Date-o;a&&clearTimeout(a),c>t||!n("enableThrottle")||l?u():a=setTimeout(u,t-c)}}function A(){--h,a.size()||h||g("onFinishedAll")}function g(e){return(e=n(e))?(e.apply(r,t(arguments).slice(1)),!0):!1}var h=0,b=-1,v=-1,p=!1;!function(){"event"==n("bind")?i():t(e).load(i)}()}function o(e,r){var o=this,i=t.extend({},o.configuration,r),l={};return o.config=function(t,e){return e===n?i[t]:(i[t]=e,o)},o.addItems=function(e){return l.a&&l.a("string"===t.type(e)?t(e):e),o},o.getItems=function(){return l.g?l.g():{}},o.update=function(t){return l.e&&l.e({},!t),o},o.loadAll=function(){return l.e&&l.e({all:!0},!0),o},o.destroy=function(){t(o.config("appendScroll")).off("."+o.name,l.e),l={}},a(o,o.config,e,l),o.config("chainable")?e:o}t.fn.Lazy=t.fn.lazy=function(t){return new o(this,t)},t.extend(o.prototype,{name:"lazy",configuration:{chainable:!0,autoDestroy:!0,bind:"load",threshold:500,visibleOnly:!1,appendScroll:e,scrollDirection:"both",imageBase:null,defaultImage:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",placeholder:null,delay:-1,combined:!1,attribute:"data-src",retinaAttribute:"data-retina",loaderAttribute:"data-loader",removeAttribute:!0,handledName:"handled",effect:"show",effectTime:0,enableThrottle:!0,throttle:250,beforeLoad:null,afterLoad:null,onError:null,onFinishedAll:null}})}(jQuery,window,document); \ No newline at end of file +/*! jQuery Lazy 0.6.4 - MIT & GPL-2.0 license - Copyright 2012-2015 Daniel 'Eisbehr' Kern */ +!function(t,e,r,n){"use strict";function a(r,n,a,o){function i(){p=e.devicePixelRatio>1,l(a),n("delay")>=0&&setTimeout(function(){u(!0)},n("delay")),(n("delay")<0||n("combined"))&&(o.e=m(n("throttle"),function(t){"resize"===t.type&&(b=v=-1),u(t.all)}),o.a=function(t){l(t),a.push.apply(a,t)},o.g=function(){return a},u(),t(n("appendScroll")).on("scroll."+r.name+" resize."+r.name,o.e))}function l(e){if(e=t(e).filter(function(){return!t(this).data(n("handledName"))&&(t(this).attr(n("attribute"))||t(this).attr(n("loaderAttribute")))}).data("plugin_"+r.name,r),n("defaultImage")||n("placeholder"))for(var a=0;ae.top&&-ae.left&&-a=0?b:b=t(e).width()}function s(){return v>=0?v:v=t(e).height()}function m(t,e){var a,o=0;return function(i,l){function u(){o=+new Date,e.call(r,i)}var c=+new Date-o;a&&clearTimeout(a),c>t||!n("enableThrottle")||l?u():a=setTimeout(u,t-c)}}function A(){--h,a.size()||h||g("onFinishedAll")}function g(t,e,a){return(t=n(t))?(t.apply(r,[].slice.call(arguments,1)),!0):!1}var h=0,b=-1,v=-1,p=!1;!function(){"event"==n("bind")?i():t(e).load(i)}()}function o(e,r){var o=this,i=t.extend({},o.configuration,r),l={};return o.config=function(t,e){return e===n?i[t]:(i[t]=e,o)},o.addItems=function(e){return l.a&&l.a("string"===t.type(e)?t(e):e),o},o.getItems=function(){return l.g?l.g():{}},o.update=function(t){return l.e&&l.e({},!t),o},o.loadAll=function(){return l.e&&l.e({all:!0},!0),o},o.destroy=function(){return t(o.config("appendScroll")).off("."+o.name,l.e),l={},n},a(o,o.config,e,l),o.config("chainable")?e:o}t.fn.Lazy=t.fn.lazy=function(t){return new o(this,t)},t.extend(o.prototype,{name:"lazy",configuration:{chainable:!0,autoDestroy:!0,bind:"load",threshold:500,visibleOnly:!1,appendScroll:e,scrollDirection:"both",imageBase:null,defaultImage:"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",placeholder:null,delay:-1,combined:!1,attribute:"data-src",retinaAttribute:"data-retina",loaderAttribute:"data-loader",removeAttribute:!0,handledName:"handled",effect:"show",effectTime:0,enableThrottle:!0,throttle:250,beforeLoad:null,afterLoad:null,onError:null,onFinishedAll:null}})}(jQuery,window,document); \ No newline at end of file diff --git a/package.json b/package.json index 274755c..d01477b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "jquery-lazy", "title": "jQuery Lazy - Delayed Content, Image and Background Loader", - "version": "0.6.3", + "version": "0.6.4", "description": "Lazy is a fast, feature-rich and lightweight delayed content loading plugin for jQuery. It's designed to speed up page loading times and decrease traffic to your users by only loading the content in view.", "homepage": "http://jquery.eisbehr.de/lazy/", "bugs": "http://github.com/eisbehr-/jquery.lazy/issues",