@area17/a17-lazyload
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -75,2 +75,3 @@ (function () { | ||
var dlazyload = el.getAttribute('data-lazyload') !== null; | ||
var autoplay = el.getAttribute('autoplay'); | ||
// | ||
@@ -95,2 +96,8 @@ if (srcset) { | ||
} | ||
if (autoplay) { | ||
try { | ||
el.play(); | ||
} catch(err) { | ||
} | ||
} | ||
} | ||
@@ -97,0 +104,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(){var e,t,n,a,o,r={pageUpdatedEventName:"page:updated",elements:"img[data-src], img[data-srcset], source[data-srcset], iframe[data-src], video[data-src], [data-lazyload]",rootMargin:"0px",threshold:0,maxFrameCount:10},i=[];function d(e){e.removeAttribute("data-src"),e.removeAttribute("data-srcset"),e.removeAttribute("data-lazyload")}function l(){this.removeEventListener("load",l),d(this)}function s(e){var t=e.getAttribute("data-srcset"),n=e.getAttribute("data-src"),a=null!==e.getAttribute("data-lazyload");t&&(e.setAttribute("srcset",t),window.picturefill&&window.picturefill({elements:[e]})),n&&(e.src=n),a&&(e.setAttribute("data-lazyloaded",""),e.removeEventListener("load",l),d(e))}function c(e){0===n&&a.disconnect();for(var t=0;t<e.length;t++){var o=e[t];o.intersectionRatio>0&&(n--,a.unobserve(o.target),o.target.addEventListener("load",l,!1),s(o.target))}}function u(){var m,v,f;if("really-old"===o){for(n=i.length,m=0;m<n;m++)i[m]&&(s(i[m]),d(i[m]));i=[]}else if("old"===o){if(t===r.maxFrameCount){for(n=i.length,m=0;m<n;m++)if(i[m]&&void 0===i[m].lazyloaded&&(v=i[m],f=void 0,(f=(v="SOURCE"===v.tagName?v.parentNode:v).getBoundingClientRect()).bottom>0&&f.right>0&&f.left<(window.innerWidth||document.documentElement.clientWidth)&&f.top<(window.innerHeight||document.documentElement.clientHeight))){var g=i[m];i[m]=void 0,g.lazyloaded=!0,g.addEventListener("load",l,!1),s(g)}for(m=0;m<n;m++)void 0===i[m]&&i.splice(m,1);n=i.length,t=-1}n>0&&(t++,e=window.requestAnimationFrame(u))}else if("new"===o)for(a=new IntersectionObserver(c,{rootMargin:r.rootMargin,threshold:r.threshold}),n=i.length,m=0;m<n;m++)i[m]&&void 0===i[m].lazyloaded&&a.observe(i[m])}function m(){if("old"===o)try{cancelAnimationFrame(e)}catch(d){}else if("new"===o)try{a.disconnect()}catch(d){}i=function(e){var t=[],n=0;for(t=[],n=e.length;n;)t[--n]=e[n];return t}(document.querySelectorAll(r.elements)),n=i.length,t=r.maxFrameCount,u()}var v=function(e){for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);o="addEventListener"in window&&window.requestAnimationFrame&&void 0!==typeof document.body.getBoundingClientRect?"IntersectionObserver"in window?"new":"old":"really-old",m(),r.pageUpdatedEventName&&document.addEventListener(r.pageUpdatedEventName,m,!0)};"undefined"!=typeof exports?module.exports=v:window.lazyload=v}(); | ||
!function(){var e,t,n,a,o,r={pageUpdatedEventName:"page:updated",elements:"img[data-src], img[data-srcset], source[data-srcset], iframe[data-src], video[data-src], [data-lazyload]",rootMargin:"0px",threshold:0,maxFrameCount:10},i=[];function d(e){e.removeAttribute("data-src"),e.removeAttribute("data-srcset"),e.removeAttribute("data-lazyload")}function l(){this.removeEventListener("load",l),d(this)}function c(e){var t=e.getAttribute("data-srcset"),n=e.getAttribute("data-src"),a=null!==e.getAttribute("data-lazyload"),o=e.getAttribute("autoplay");if(t&&(e.setAttribute("srcset",t),window.picturefill&&window.picturefill({elements:[e]})),n&&(e.src=n),a&&(e.setAttribute("data-lazyloaded",""),e.removeEventListener("load",l),d(e)),o)try{e.play()}catch(r){}}function s(e){0===n&&a.disconnect();for(var t=0;t<e.length;t++){var o=e[t];o.intersectionRatio>0&&(n--,a.unobserve(o.target),o.target.addEventListener("load",l,!1),c(o.target))}}function u(){var m,v,f;if("really-old"===o){for(n=i.length,m=0;m<n;m++)i[m]&&(c(i[m]),d(i[m]));i=[]}else if("old"===o){if(t===r.maxFrameCount){for(n=i.length,m=0;m<n;m++)if(i[m]&&void 0===i[m].lazyloaded&&(v=i[m],f=void 0,(f=(v="SOURCE"===v.tagName?v.parentNode:v).getBoundingClientRect()).bottom>0&&f.right>0&&f.left<(window.innerWidth||document.documentElement.clientWidth)&&f.top<(window.innerHeight||document.documentElement.clientHeight))){var g=i[m];i[m]=void 0,g.lazyloaded=!0,g.addEventListener("load",l,!1),c(g)}for(m=0;m<n;m++)void 0===i[m]&&i.splice(m,1);n=i.length,t=-1}n>0&&(t++,e=window.requestAnimationFrame(u))}else if("new"===o)for(a=new IntersectionObserver(s,{rootMargin:r.rootMargin,threshold:r.threshold}),n=i.length,m=0;m<n;m++)i[m]&&void 0===i[m].lazyloaded&&a.observe(i[m])}function m(){if("old"===o)try{cancelAnimationFrame(e)}catch(d){}else if("new"===o)try{a.disconnect()}catch(d){}i=function(e){var t=[],n=0;for(t=[],n=e.length;n;)t[--n]=e[n];return t}(document.querySelectorAll(r.elements)),n=i.length,t=r.maxFrameCount,u()}var v=function(e){for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);o="addEventListener"in window&&window.requestAnimationFrame&&void 0!==typeof document.body.getBoundingClientRect?"IntersectionObserver"in window?"new":"old":"really-old",m(),r.pageUpdatedEventName&&document.addEventListener(r.pageUpdatedEventName,m,!0)};"undefined"!=typeof exports?module.exports=v:window.lazyload=v}(); |
{ | ||
"name": "@area17/a17-lazyload", | ||
"description": "A simple, tiny, no dependency, lazy loader - by A17", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "./dist/a17-lazyload.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12665
6
235