From e7ce4cadfa2bdc61fbb619fc1927ba34d38af721 Mon Sep 17 00:00:00 2001 From: thinker3197 Date: Mon, 28 Aug 2017 22:26:18 +0530 Subject: [PATCH] Fix issue #24 --- dist/progressively.min.js | 2 +- docs/progressively.min.js | 2 +- package.json | 2 +- src/progressively.js | 13 ------------- 4 files changed, 3 insertions(+), 16 deletions(-) diff --git a/dist/progressively.min.js b/dist/progressively.min.js index b4df918..09ee76a 100644 --- a/dist/progressively.min.js +++ b/dist/progressively.min.js @@ -1 +1 @@ -!function(e,t){"function"==typeof define&&define.amd?define(function(){return t(e)}):"object"==typeof exports?module.exports=t:e.progressively=t(e)}(this,function(e){"use strict";function t(e,t){var n={};for(var o in e)n[o]=t.hasOwnProperty(o)?t[o]:e[o];return n}function n(e){return null===e.offsetParent}function o(e){if(n(e))return!1;var t=e.getBoundingClientRect(),o=t.top,s=t.height;e=e.parentNode;do{if(t=e.getBoundingClientRect(),!(o<=t.bottom))return!1;if(o+s<=t.top)return!1;e=e.parentNode}while(e!==document.body&&e!==document);return o<=document.documentElement.clientHeight}function s(e,t){setTimeout(function(){var n=new Image;n.onload=function(){e.classList.remove("progressive--not-loaded"),e.classList.add("progressive--is-loaded"),e.classList.contains("progressive__bg")?e.style["background-image"]='url("'+this.src+'")':e.src=this.src,d(e)},r()=0;--t)e=l[t],o(e)&&(e.classList.contains("progressive--not-loaded")||e.classList.contains("progressive--loaded-sm"))&&(s(e,c),e.classList.contains("progressive--loaded-sm")&&u.push(e),l.splice(t,1));if(r()>=c.smBreakpoint)for(var n=u.length-1;n>=0;--n)e=u[n],o(e)&&(e.classList.contains("progressive--not-loaded")||e.classList.contains("progressive--loaded-sm"))&&(s(e,c),u.splice(t,1));this.check()},v.check=function(){l.length||u.length||(c.onLoadComplete(),this.drop())},v.drop=function(){document.removeEventListener?(e.removeEventListener("scroll",i),e.removeEventListener("resize",i)):(e.detachEvent("onscroll",i),e.detachEvent("onresize",i)),clearTimeout(a)},v}); \ No newline at end of file +!function(e,t){"function"==typeof define&&define.amd?define(function(){return t(e)}):"object"==typeof exports?module.exports=t:e.progressively=t(e)}(this,function(e){"use strict";function t(e,t){var n={};for(var o in e)n[o]=t.hasOwnProperty(o)?t[o]:e[o];return n}function n(e){var t=e.getBoundingClientRect(),n=t.top,o=t.height;e=e.parentNode;do{if(t=e.getBoundingClientRect(),!(n<=t.bottom))return!1;if(n+o<=t.top)return!1;e=e.parentNode}while(e!==document.body&&e!==document);return n<=document.documentElement.clientHeight}function o(e,t){setTimeout(function(){var n=new Image;n.onload=function(){e.classList.remove("progressive--not-loaded"),e.classList.add("progressive--is-loaded"),e.classList.contains("progressive__bg")?e.style["background-image"]='url("'+this.src+'")':e.src=this.src,a(e)},s()=0;--t)e=d[t],n(e)&&(e.classList.contains("progressive--not-loaded")||e.classList.contains("progressive--loaded-sm"))&&(o(e,i),e.classList.contains("progressive--loaded-sm")&&l.push(e),d.splice(t,1));if(s()>=i.smBreakpoint)for(var r=l.length-1;r>=0;--r)e=l[r],n(e)&&(e.classList.contains("progressive--not-loaded")||e.classList.contains("progressive--loaded-sm"))&&(o(e,i),l.splice(t,1));this.check()},u.check=function(){d.length||l.length||(i.onLoadComplete(),this.drop())},u.drop=function(){document.removeEventListener?(e.removeEventListener("scroll",r),e.removeEventListener("resize",r)):(e.detachEvent("onscroll",r),e.detachEvent("onresize",r)),clearTimeout(c)},u}); \ No newline at end of file diff --git a/docs/progressively.min.js b/docs/progressively.min.js index 338508c..c0d2a08 100644 --- a/docs/progressively.min.js +++ b/docs/progressively.min.js @@ -4,4 +4,4 @@ * @license MIT licensed * * Copyright (C) 2016-17 Ashish - */!function(e,t){"function"==typeof define&&define.amd?define(function(){return t(e)}):"object"==typeof exports?module.exports=t:e.progressively=t(e)}(this,function(e){"use strict";function t(e,t){var n={};for(var o in e)n[o]=t.hasOwnProperty(o)?t[o]:e[o];return n}function n(e){return null===e.offsetParent}function o(e){if(n(e))return!1;var t=e.getBoundingClientRect(),o=t.top,s=t.height;e=e.parentNode;do{if(t=e.getBoundingClientRect(),!(o<=t.bottom))return!1;if(o+s<=t.top)return!1;e=e.parentNode}while(e!==document.body&&e!==document);return o<=document.documentElement.clientHeight}function s(e,t){setTimeout(function(){var n=new Image;n.onload=function(){e.classList.remove("progressive--not-loaded"),e.classList.add("progressive--is-loaded"),e.classList.contains("progressive__bg")?e.style["background-image"]='url("'+this.src+'")':e.src=this.src,d(e)},r()=0;--t)e=l[t],o(e)&&(e.classList.contains("progressive--not-loaded")||e.classList.contains("progressive--loaded-sm"))&&(s(e,c),e.classList.contains("progressive--loaded-sm")&&u.push(e),l.splice(t,1));if(r()>=c.smBreakpoint)for(var n=u.length-1;n>=0;--n)e=u[n],o(e)&&(e.classList.contains("progressive--not-loaded")||e.classList.contains("progressive--loaded-sm"))&&(s(e,c),u.splice(t,1));this.check()},v.check=function(){l.length||u.length||(c.onLoadComplete(),this.drop())},v.drop=function(){document.removeEventListener?(e.removeEventListener("scroll",i),e.removeEventListener("resize",i)):(e.detachEvent("onscroll",i),e.detachEvent("onresize",i)),clearTimeout(a)},v}); \ No newline at end of file + */!function(e,t){"function"==typeof define&&define.amd?define(function(){return t(e)}):"object"==typeof exports?module.exports=t:e.progressively=t(e)}(this,function(e){"use strict";function t(e,t){var n={};for(var o in e)n[o]=t.hasOwnProperty(o)?t[o]:e[o];return n}function n(e){var t=e.getBoundingClientRect(),n=t.top,o=t.height;e=e.parentNode;do{if(t=e.getBoundingClientRect(),!(n<=t.bottom))return!1;if(n+o<=t.top)return!1;e=e.parentNode}while(e!==document.body&&e!==document);return n<=document.documentElement.clientHeight}function o(e,t){setTimeout(function(){var n=new Image;n.onload=function(){e.classList.remove("progressive--not-loaded"),e.classList.add("progressive--is-loaded"),e.classList.contains("progressive__bg")?e.style["background-image"]='url("'+this.src+'")':e.src=this.src,a(e)},s()=0;--t)e=d[t],n(e)&&(e.classList.contains("progressive--not-loaded")||e.classList.contains("progressive--loaded-sm"))&&(o(e,i),e.classList.contains("progressive--loaded-sm")&&l.push(e),d.splice(t,1));if(s()>=i.smBreakpoint)for(var r=l.length-1;r>=0;--r)e=l[r],n(e)&&(e.classList.contains("progressive--not-loaded")||e.classList.contains("progressive--loaded-sm"))&&(o(e,i),l.splice(t,1));this.check()},u.check=function(){d.length||l.length||(i.onLoadComplete(),this.drop())},u.drop=function(){document.removeEventListener?(e.removeEventListener("scroll",r),e.removeEventListener("resize",r)):(e.detachEvent("onscroll",r),e.detachEvent("onresize",r)),clearTimeout(c)},u}); \ No newline at end of file diff --git a/package.json b/package.json index 2835da8..beb3051 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "progressively", - "version": "1.1.4", + "version": "1.1.5", "description": "A JavaScript library to load images progressively", "main": "dist/progressively.min.js", "scripts": { diff --git a/src/progressively.js b/src/progressively.js index 46a1231..b125be2 100644 --- a/src/progressively.js +++ b/src/progressively.js @@ -34,25 +34,12 @@ return o } -/** - * Checks, if element is hidden - * @param object DOMElement - * @return {Boolean} [description] - */ - function isHidden (el) { - return (el.offsetParent === null) - } - /** * Check if element is currently visible * @param object DOMElement * @return boolean */ function inView (el) { - if (isHidden(el)) { - return false - } - var box = el.getBoundingClientRect() var top = box.top var height = box.height