New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@egjs/imready

Package Overview
Dependencies
Maintainers
8
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@egjs/imready - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

1

declaration/loaders/ElementLoader.d.ts

@@ -7,2 +7,3 @@ import { ImReadyLoaderOptions } from "../types";

setHasLoading(hasLoading: boolean): void;
check(): boolean;
checkElement(): boolean;

@@ -9,0 +10,0 @@ destroy(): void;

@@ -7,3 +7,3 @@ /*

repository: https://github.com/naver/egjs-imready
version: 1.1.0
version: 1.1.1
*/

@@ -245,3 +245,3 @@ 'use strict';

__proto.check = function () {
if (this.isSkip || hasSkipAttribute(this.element) || !this.checkElement()) {
if (this.isSkip || !this.checkElement()) {
// I'm Ready

@@ -374,4 +374,13 @@ this.onAlreadyReady(true);

__proto.checkElement = function () {
if (!this.hasDataSize) {
__proto.check = function () {
if (this.isSkip) {
// I'm Ready
this.onAlreadyReady(true);
return false;
}
if (this.hasDataSize) {
addAutoSizer(this.element, this.options.prefix);
this.onAlreadyPreReady();
} else {
// has not data size

@@ -384,2 +393,6 @@ this.trigger("requestChildren");

__proto.checkElement = function () {
return true;
};
__proto.destroy = function () {

@@ -386,0 +399,0 @@ this.removeAutoSizer();

@@ -7,3 +7,3 @@ /*

repository: https://github.com/naver/egjs-imready
version: 1.1.0
version: 1.1.1
*/

@@ -243,3 +243,3 @@ import Component from '@egjs/component';

__proto.check = function () {
if (this.isSkip || hasSkipAttribute(this.element) || !this.checkElement()) {
if (this.isSkip || !this.checkElement()) {
// I'm Ready

@@ -372,4 +372,13 @@ this.onAlreadyReady(true);

__proto.checkElement = function () {
if (!this.hasDataSize) {
__proto.check = function () {
if (this.isSkip) {
// I'm Ready
this.onAlreadyReady(true);
return false;
}
if (this.hasDataSize) {
addAutoSizer(this.element, this.options.prefix);
this.onAlreadyPreReady();
} else {
// has not data size

@@ -382,2 +391,6 @@ this.trigger("requestChildren");

__proto.checkElement = function () {
return true;
};
__proto.destroy = function () {

@@ -384,0 +397,0 @@ this.removeAutoSizer();

@@ -7,3 +7,3 @@ /*

repository: https://github.com/naver/egjs-imready
version: 1.1.0
version: 1.1.1
*/

@@ -598,3 +598,3 @@ (function (global, factory) {

__proto.check = function () {
if (this.isSkip || hasSkipAttribute(this.element) || !this.checkElement()) {
if (this.isSkip || !this.checkElement()) {
// I'm Ready

@@ -727,4 +727,13 @@ this.onAlreadyReady(true);

__proto.checkElement = function () {
if (!this.hasDataSize) {
__proto.check = function () {
if (this.isSkip) {
// I'm Ready
this.onAlreadyReady(true);
return false;
}
if (this.hasDataSize) {
addAutoSizer(this.element, this.options.prefix);
this.onAlreadyPreReady();
} else {
// has not data size

@@ -737,2 +746,6 @@ this.trigger("requestChildren");

__proto.checkElement = function () {
return true;
};
__proto.destroy = function () {

@@ -739,0 +752,0 @@ this.removeAutoSizer();

4

dist/imready.min.js

@@ -7,5 +7,5 @@ /*

repository: https://github.com/naver/egjs-imready
version: 1.1.0
version: 1.1.1
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t=t||self).eg=t.eg||{},t.eg.ImReady=e())}(this,function(){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var a=function(){return(a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function d(t){return void 0===t}var t=function(){function t(){this.options={},this._eventHandler={}}var e=t.prototype;return e.trigger=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(!(0<(a=this._eventHandler[t]||[]).length))return!0;var o=n[0]||{},i=n.slice(1),a=a.concat(),s=!1;o.eventType=t,o.stop=function(){s=!0},o.currentTarget=this;var u=[o];return 1<=i.length&&(u=u.concat(i)),a.forEach(function(t){t.apply(e,u)}),!s},e.once=function(n,r){var o,i=this;if("object"==typeof n&&d(r)){var t,e=n;for(t in e)this.once(t,e[t]);return this}return"string"==typeof n&&"function"==typeof r&&(o=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];r.apply(i,t),i.off(n,o)},this.on(n,o)),this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&d(e)){var n,r=t;for(n in r)this.on(n,r[n]);return this}var o;return"string"==typeof t&&"function"==typeof e&&(d(o=this._eventHandler[t])&&(this._eventHandler[t]=[],o=this._eventHandler[t]),o.push(e)),this},e.off=function(t,e){var n,r;if(d(t))return this._eventHandler={},this;if(d(e)){if("string"==typeof t)return delete this._eventHandler[t],this;var o,i=t;for(o in i)this.off(o,i[o]);return this}var a=this._eventHandler[t];if(a){var s=0;try{for(var u=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(a),h=u.next();!h.done;h=u.next()){if(h.value===e){a.splice(s,1);break}s++}}catch(t){n={error:t}}finally{try{h&&!h.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}return this},t.VERSION="2.2.2",t}(),e="undefined"!=typeof window,n=e?window.navigator.userAgent:"",o=e&&!!("getComputedStyle"in window),s=/MSIE|Trident|Windows Phone|Edge/.test(n),u=e&&!!("addEventListener"in document),h="width",c="height";function f(t,e){return t.getAttribute(e)||""}function l(t){return[].slice.call(t)}function y(t){return"loading"in t&&"lazy"===t.getAttribute("loading")}function p(t,e){return void 0===e&&(e="data-"),!!t.getAttribute(e+"skip")}function v(t,e,n){u?t.addEventListener(e,n,!1):t.attachEvent?t.attachEvent("on"+e,n):t["on"+e]=n}function g(t,e,n){t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent?t.detachEvent("on"+e,n):t["on"+e]=null}function R(t,e){var n=t["client"+e]||t["offset"+e];return parseFloat(n||(t=t,((o?window.getComputedStyle(t):t.currentStyle)||{})[e.toLowerCase()]))||0}function m(t,e,n){var r=l(t.querySelectorAll(function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var r=Array(t),o=0,e=0;e<n;e++)for(var i=arguments[e],a=0,s=i.length;a<s;a++,o++)r[o]=i[a];return r}(["["+n+"skip] ["+n+"width]"],e.map(function(t){return["["+n+"skip] "+t,t+"["+n+"skip]","["+n+"width] "+t].join(", ")})).join(", ")));return l(t.querySelectorAll("["+n+"width], "+e.join(", "))).filter(function(t){return-1===r.indexOf(t)})}var E=[];function C(t,e){void 0===e&&(e="data-");var n,r=t.__PREFIX__||e,o=parseInt(f(t,""+r+h),10)||0,e=parseInt(f(t,""+r+c),10)||0;f(t,r+"fixed")===c?(n=R(t,"Height")||e,t.style[h]=o/e*n+"px"):(n=R(t,"Width")||o,t.style[c]=e/o*n+"px")}function S(){E.forEach(function(t){C(t)})}var P,e=function(o){function t(t,e){void 0===e&&(e={});var n,r=o.call(this)||this;return r.isReady=!1,r.isPreReady=!1,r.hasDataSize=!1,r.hasLoading=!1,r.isSkip=!1,r.onCheck=function(t){r.destroy(),t&&"error"===t.type&&r.onError(r.element);t=!r.hasDataSize&&!r.hasLoading;r.onReady(t)},r.options=a({prefix:"data-"},e),r.element=t,r.hasDataSize=(n=t,void 0===(e=r.options.prefix)&&(e="data-"),!!n.getAttribute(e+"width")),r.hasLoading=y(t),r.isSkip=p(r.element),r}i(t,o);var e=t.prototype;return e.check=function(){return this.isSkip||p(this.element)||!this.checkElement()?(this.onAlreadyReady(!0),!1):(this.hasDataSize&&(t=this.element,e=this.options.prefix,E.length||v(window,"resize",S),t.__PREFIX__=e,E.push(t),C(t)),(this.hasDataSize||this.hasLoading)&&this.onAlreadyPreReady(),!0);var t,e},e.addEvents=function(){var e=this,n=this.element;this.constructor.EVENTS.forEach(function(t){v(n,t,e.onCheck)})},e.destroy=function(){var e=this,n=this.element;this.constructor.EVENTS.forEach(function(t){g(n,t,e.onCheck)}),this.removeAutoSizer()},e.removeAutoSizer=function(){var t,e,n;this.hasDataSize&&(n=this.options.prefix,t=this.element,e=n,(n=E.indexOf(t))<0||(e=f(t,e+"fixed"),delete t.__PREFIX__,t.style[e===c?h:c]="",E.splice(n,1),E.length||g(window,"resize",S)))},e.onError=function(t){this.trigger("error",{element:this.element,target:t})},e.onPreReady=function(){this.isPreReady||(this.isPreReady=!0,this.trigger("preReady",{element:this.element,hasLoading:this.hasLoading,isSkip:this.isSkip}))},e.onReady=function(t){this.isReady||(t&&(this.isPreReady=!0),this.removeAutoSizer(),this.isReady=!0,this.trigger("ready",{element:this.element,withPreReady:t,hasLoading:this.hasLoading,isSkip:this.isSkip}))},e.onAlreadyError=function(t){var e=this;setTimeout(function(){e.onError(t)})},e.onAlreadyPreReady=function(){var t=this;setTimeout(function(){t.onPreReady()})},e.onAlreadyReady=function(t){var e=this;setTimeout(function(){e.onReady(t)})},t.EVENTS=[],t}(t),k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}i(e,t);var n=e.prototype;return n.setHasLoading=function(t){this.hasLoading=t},n.checkElement=function(){return this.hasDataSize||this.trigger("requestChildren"),!0},n.destroy=function(){this.removeAutoSizer(),this.trigger("requestDestroy")},n.onAlreadyPreReady=function(){t.prototype.onAlreadyPreReady.call(this),this.trigger("reqeustReadyChildren")},e.EVENTS=[],e}(e),t=function(n){function t(t){void 0===t&&(t={});var e=n.call(this)||this;return e.readyCount=0,e.preReadyCount=0,e.totalCount=0,e.totalErrorCount=0,e.isPreReadyOver=!0,e.elementInfos=[],e.options=a({loaders:{},prefix:"data-"},t),e}i(t,n);var e=t.prototype;return e.check=function(t){var i=this,n=this.options.prefix;this.clear(),this.elementInfos=l(t).map(function(t,o){var e=i.getLoader(t,{prefix:n});return e.check(),e.on("error",function(t){i.onError(o,t.target)}).on("preReady",function(t){var e=i.elementInfos[o];e.hasLoading=t.hasLoading,e.isSkip=t.isSkip;t=i.checkPreReady(o);i.onPreReadyElement(o),t&&i.onPreReady()}).on("ready",function(t){var e=t.withPreReady,n=t.hasLoading,r=t.isSkip,t=i.elementInfos[o];t.hasLoading=n,t.isSkip=r;t=e&&i.checkPreReady(o),r=i.checkReady(o);e&&i.onPreReadyElement(o),i.onReadyElement(o),t&&i.onPreReady(),r&&i.onReady()}),{loader:e,element:t,hasLoading:!1,hasError:!1,isPreReady:!1,isReady:!1,isSkip:!1}});t=this.elementInfos.length;return(this.totalCount=t)||setTimeout(function(){i.onPreReady(),i.onReady()}),this},e.getTotalCount=function(){return this.totalCount},e.isPreReady=function(){return this.elementInfos.every(function(t){return t.isPreReady})},e.isReady=function(){return this.elementInfos.every(function(t){return t.isReady})},e.hasError=function(){return 0<this.totalErrorCount},e.clear=function(){this.isPreReadyOver=!1,this.totalCount=0,this.preReadyCount=0,this.readyCount=0,this.totalErrorCount=0,this.elementInfos.forEach(function(t){!t.isReady&&t.loader&&t.loader.destroy()}),this.elementInfos=[]},e.destroy=function(){this.clear(),this.off()},e.getLoader=function(e,t){var n=this,r=e.tagName.toLowerCase(),o=this.options.loaders,i=Object.keys(o);if(o[r])return new o[r](e,t);var a=new k(e,t),s=l(e.querySelectorAll(i.join(", ")));a.setHasLoading(s.some(y));var u=!1,h=this.clone().on("error",function(t){a.onError(t.target)}).on("ready",function(){a.onReady(u)});return a.on("requestChildren",function(){var t=m(e,i,n.options.prefix);h.check(t).on("preReady",function(t){(u=t.isReady)||a.onPreReady()})}).on("reqeustReadyChildren",function(){h.check(s)}).on("requestDestroy",function(){h.destroy()}),a},e.clone=function(){return new t(a({},this.options))},e.checkPreReady=function(t){return this.elementInfos[t].isPreReady=!0,++this.preReadyCount,!(this.preReadyCount<this.totalCount)},e.checkReady=function(t){return this.elementInfos[t].isReady=!0,++this.readyCount,!(this.readyCount<this.totalCount)},e.onError=function(t,e){var n=this.elementInfos[t];n.hasError=!0,this.trigger("error",{element:n.element,index:t,target:e,errorCount:this.getErrorCount(),totalErrorCount:++this.totalErrorCount})},e.onPreReadyElement=function(t){var e=this.elementInfos[t];this.trigger("preReadyElement",{element:e.element,index:t,preReadyCount:this.preReadyCount,readyCount:this.readyCount,totalCount:this.totalCount,isPreReady:this.isPreReady(),isReady:this.isReady(),hasLoading:e.hasLoading,isSkip:e.isSkip})},e.onPreReady=function(){this.isPreReadyOver=!0,this.trigger("preReady",{readyCount:this.readyCount,totalCount:this.totalCount,isReady:this.isReady(),hasLoading:this.hasLoading()})},e.onReadyElement=function(t){var e=this.elementInfos[t];this.trigger("readyElement",{index:t,element:e.element,hasError:e.hasError,errorCount:this.getErrorCount(),totalErrorCount:this.totalErrorCount,preReadyCount:this.preReadyCount,readyCount:this.readyCount,totalCount:this.totalCount,isPreReady:this.isPreReady(),isReady:this.isReady(),hasLoading:e.hasLoading,isPreReadyOver:this.isPreReadyOver,isSkip:e.isSkip})},e.onReady=function(){this.trigger("ready",{errorCount:this.getErrorCount(),totalErrorCount:this.totalErrorCount,totalCount:this.totalCount})},e.getErrorCount=function(){return this.elementInfos.filter(function(t){return t.hasError}).length},e.hasLoading=function(){return this.elementInfos.some(function(t){return t.hasLoading})},t}(t),L=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.checkElement=function(){var t=this.element,e=t.getAttribute("src");return t.complete&&e?(t.naturalWidth||this.onAlreadyError(t),!1):(this.addEvents(),s&&t.setAttribute("src",e),!0)},e.EVENTS=["load","error"],e}(e),_=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.checkElement=function(){var t=this.element;return!(1<=t.readyState)&&(t.error?(this.onAlreadyError(t),!1):(this.addEvents(),!0))},e.EVENTS=["loadedmetadata","error"],e}(e),w=function(e){function t(t){return void 0===t&&(t={}),e.call(this,a({loaders:{img:L,video:_}},t))||this}return i(t,e),t}(t),A={__proto__:null,default:w,Manager:t,VideoLoader:_,ImageLoader:L,Loader:e};for(P in A)w[P]=A[P];return w});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t=t||self).eg=t.eg||{},t.eg.ImReady=e())}(this,function(){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var a=function(){return(a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function d(t){return void 0===t}var t=function(){function t(){this.options={},this._eventHandler={}}var e=t.prototype;return e.trigger=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(!(0<(a=this._eventHandler[t]||[]).length))return!0;var i=n[0]||{},o=n.slice(1),a=a.concat(),s=!1;i.eventType=t,i.stop=function(){s=!0},i.currentTarget=this;var u=[i];return 1<=o.length&&(u=u.concat(o)),a.forEach(function(t){t.apply(e,u)}),!s},e.once=function(n,r){var i,o=this;if("object"==typeof n&&d(r)){var t,e=n;for(t in e)this.once(t,e[t]);return this}return"string"==typeof n&&"function"==typeof r&&(i=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];r.apply(o,t),o.off(n,i)},this.on(n,i)),this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&d(e)){var n,r=t;for(n in r)this.on(n,r[n]);return this}var i;return"string"==typeof t&&"function"==typeof e&&(d(i=this._eventHandler[t])&&(this._eventHandler[t]=[],i=this._eventHandler[t]),i.push(e)),this},e.off=function(t,e){var n,r;if(d(t))return this._eventHandler={},this;if(d(e)){if("string"==typeof t)return delete this._eventHandler[t],this;var i,o=t;for(i in o)this.off(i,o[i]);return this}var a=this._eventHandler[t];if(a){var s=0;try{for(var u=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(a),h=u.next();!h.done;h=u.next()){if(h.value===e){a.splice(s,1);break}s++}}catch(t){n={error:t}}finally{try{h&&!h.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}return this},t.VERSION="2.2.2",t}(),e="undefined"!=typeof window,n=e?window.navigator.userAgent:"",o=e&&!!("getComputedStyle"in window),s=/MSIE|Trident|Windows Phone|Edge/.test(n),u=e&&!!("addEventListener"in document),h="width",c="height";function f(t,e){return t.getAttribute(e)||""}function l(t){return[].slice.call(t)}function y(t){return"loading"in t&&"lazy"===t.getAttribute("loading")}function p(t,e,n){u?t.addEventListener(e,n,!1):t.attachEvent?t.attachEvent("on"+e,n):t["on"+e]=n}function g(t,e,n){t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent?t.detachEvent("on"+e,n):t["on"+e]=null}function v(t,e){var n=t["client"+e]||t["offset"+e];return parseFloat(n||(t=t,((o?window.getComputedStyle(t):t.currentStyle)||{})[e.toLowerCase()]))||0}function R(t,e,n){var r=l(t.querySelectorAll(function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;for(var r=Array(t),i=0,e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}(["["+n+"skip] ["+n+"width]"],e.map(function(t){return["["+n+"skip] "+t,t+"["+n+"skip]","["+n+"width] "+t].join(", ")})).join(", ")));return l(t.querySelectorAll("["+n+"width], "+e.join(", "))).filter(function(t){return-1===r.indexOf(t)})}var m=[];function E(t,e){m.length||p(window,"resize",S),t.__PREFIX__=e,m.push(t),C(t)}function C(t,e){void 0===e&&(e="data-");var n,r=t.__PREFIX__||e,i=parseInt(f(t,""+r+h),10)||0,e=parseInt(f(t,""+r+c),10)||0;f(t,r+"fixed")===c?(n=v(t,"Height")||e,t.style[h]=i/e*n+"px"):(n=v(t,"Width")||i,t.style[c]=e/i*n+"px")}function S(){m.forEach(function(t){C(t)})}var P,e=function(o){function t(t,e){void 0===e&&(e={});var n,r,i=o.call(this)||this;return i.isReady=!1,i.isPreReady=!1,i.hasDataSize=!1,i.hasLoading=!1,i.isSkip=!1,i.onCheck=function(t){i.destroy(),t&&"error"===t.type&&i.onError(i.element);t=!i.hasDataSize&&!i.hasLoading;i.onReady(t)},i.options=a({prefix:"data-"},e),i.element=t,i.hasDataSize=(n=t,void 0===(e=i.options.prefix)&&(e="data-"),!!n.getAttribute(e+"width")),i.hasLoading=y(t),i.isSkip=(t=i.element,void 0===r&&(r="data-"),!!t.getAttribute(r+"skip")),i}i(t,o);var e=t.prototype;return e.check=function(){return this.isSkip||!this.checkElement()?(this.onAlreadyReady(!0),!1):(this.hasDataSize&&E(this.element,this.options.prefix),(this.hasDataSize||this.hasLoading)&&this.onAlreadyPreReady(),!0)},e.addEvents=function(){var e=this,n=this.element;this.constructor.EVENTS.forEach(function(t){p(n,t,e.onCheck)})},e.destroy=function(){var e=this,n=this.element;this.constructor.EVENTS.forEach(function(t){g(n,t,e.onCheck)}),this.removeAutoSizer()},e.removeAutoSizer=function(){var t,e,n;this.hasDataSize&&(n=this.options.prefix,t=this.element,e=n,(n=m.indexOf(t))<0||(e=f(t,e+"fixed"),delete t.__PREFIX__,t.style[e===c?h:c]="",m.splice(n,1),m.length||g(window,"resize",S)))},e.onError=function(t){this.trigger("error",{element:this.element,target:t})},e.onPreReady=function(){this.isPreReady||(this.isPreReady=!0,this.trigger("preReady",{element:this.element,hasLoading:this.hasLoading,isSkip:this.isSkip}))},e.onReady=function(t){this.isReady||(t&&(this.isPreReady=!0),this.removeAutoSizer(),this.isReady=!0,this.trigger("ready",{element:this.element,withPreReady:t,hasLoading:this.hasLoading,isSkip:this.isSkip}))},e.onAlreadyError=function(t){var e=this;setTimeout(function(){e.onError(t)})},e.onAlreadyPreReady=function(){var t=this;setTimeout(function(){t.onPreReady()})},e.onAlreadyReady=function(t){var e=this;setTimeout(function(){e.onReady(t)})},t.EVENTS=[],t}(t),k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}i(e,t);var n=e.prototype;return n.setHasLoading=function(t){this.hasLoading=t},n.check=function(){return this.isSkip?(this.onAlreadyReady(!0),!1):(this.hasDataSize?(E(this.element,this.options.prefix),this.onAlreadyPreReady()):this.trigger("requestChildren"),!0)},n.checkElement=function(){return!0},n.destroy=function(){this.removeAutoSizer(),this.trigger("requestDestroy")},n.onAlreadyPreReady=function(){t.prototype.onAlreadyPreReady.call(this),this.trigger("reqeustReadyChildren")},e.EVENTS=[],e}(e),t=function(n){function t(t){void 0===t&&(t={});var e=n.call(this)||this;return e.readyCount=0,e.preReadyCount=0,e.totalCount=0,e.totalErrorCount=0,e.isPreReadyOver=!0,e.elementInfos=[],e.options=a({loaders:{},prefix:"data-"},t),e}i(t,n);var e=t.prototype;return e.check=function(t){var o=this,n=this.options.prefix;this.clear(),this.elementInfos=l(t).map(function(t,i){var e=o.getLoader(t,{prefix:n});return e.check(),e.on("error",function(t){o.onError(i,t.target)}).on("preReady",function(t){var e=o.elementInfos[i];e.hasLoading=t.hasLoading,e.isSkip=t.isSkip;t=o.checkPreReady(i);o.onPreReadyElement(i),t&&o.onPreReady()}).on("ready",function(t){var e=t.withPreReady,n=t.hasLoading,r=t.isSkip,t=o.elementInfos[i];t.hasLoading=n,t.isSkip=r;t=e&&o.checkPreReady(i),r=o.checkReady(i);e&&o.onPreReadyElement(i),o.onReadyElement(i),t&&o.onPreReady(),r&&o.onReady()}),{loader:e,element:t,hasLoading:!1,hasError:!1,isPreReady:!1,isReady:!1,isSkip:!1}});t=this.elementInfos.length;return(this.totalCount=t)||setTimeout(function(){o.onPreReady(),o.onReady()}),this},e.getTotalCount=function(){return this.totalCount},e.isPreReady=function(){return this.elementInfos.every(function(t){return t.isPreReady})},e.isReady=function(){return this.elementInfos.every(function(t){return t.isReady})},e.hasError=function(){return 0<this.totalErrorCount},e.clear=function(){this.isPreReadyOver=!1,this.totalCount=0,this.preReadyCount=0,this.readyCount=0,this.totalErrorCount=0,this.elementInfos.forEach(function(t){!t.isReady&&t.loader&&t.loader.destroy()}),this.elementInfos=[]},e.destroy=function(){this.clear(),this.off()},e.getLoader=function(e,t){var n=this,r=e.tagName.toLowerCase(),i=this.options.loaders,o=Object.keys(i);if(i[r])return new i[r](e,t);var a=new k(e,t),s=l(e.querySelectorAll(o.join(", ")));a.setHasLoading(s.some(y));var u=!1,h=this.clone().on("error",function(t){a.onError(t.target)}).on("ready",function(){a.onReady(u)});return a.on("requestChildren",function(){var t=R(e,o,n.options.prefix);h.check(t).on("preReady",function(t){(u=t.isReady)||a.onPreReady()})}).on("reqeustReadyChildren",function(){h.check(s)}).on("requestDestroy",function(){h.destroy()}),a},e.clone=function(){return new t(a({},this.options))},e.checkPreReady=function(t){return this.elementInfos[t].isPreReady=!0,++this.preReadyCount,!(this.preReadyCount<this.totalCount)},e.checkReady=function(t){return this.elementInfos[t].isReady=!0,++this.readyCount,!(this.readyCount<this.totalCount)},e.onError=function(t,e){var n=this.elementInfos[t];n.hasError=!0,this.trigger("error",{element:n.element,index:t,target:e,errorCount:this.getErrorCount(),totalErrorCount:++this.totalErrorCount})},e.onPreReadyElement=function(t){var e=this.elementInfos[t];this.trigger("preReadyElement",{element:e.element,index:t,preReadyCount:this.preReadyCount,readyCount:this.readyCount,totalCount:this.totalCount,isPreReady:this.isPreReady(),isReady:this.isReady(),hasLoading:e.hasLoading,isSkip:e.isSkip})},e.onPreReady=function(){this.isPreReadyOver=!0,this.trigger("preReady",{readyCount:this.readyCount,totalCount:this.totalCount,isReady:this.isReady(),hasLoading:this.hasLoading()})},e.onReadyElement=function(t){var e=this.elementInfos[t];this.trigger("readyElement",{index:t,element:e.element,hasError:e.hasError,errorCount:this.getErrorCount(),totalErrorCount:this.totalErrorCount,preReadyCount:this.preReadyCount,readyCount:this.readyCount,totalCount:this.totalCount,isPreReady:this.isPreReady(),isReady:this.isReady(),hasLoading:e.hasLoading,isPreReadyOver:this.isPreReadyOver,isSkip:e.isSkip})},e.onReady=function(){this.trigger("ready",{errorCount:this.getErrorCount(),totalErrorCount:this.totalErrorCount,totalCount:this.totalCount})},e.getErrorCount=function(){return this.elementInfos.filter(function(t){return t.hasError}).length},e.hasLoading=function(){return this.elementInfos.some(function(t){return t.hasLoading})},t}(t),L=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.checkElement=function(){var t=this.element,e=t.getAttribute("src");return t.complete&&e?(t.naturalWidth||this.onAlreadyError(t),!1):(this.addEvents(),s&&t.setAttribute("src",e),!0)},e.EVENTS=["load","error"],e}(e),_=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.checkElement=function(){var t=this.element;return!(1<=t.readyState)&&(t.error?(this.onAlreadyError(t),!1):(this.addEvents(),!0))},e.EVENTS=["loadedmetadata","error"],e}(e),w=function(e){function t(t){return void 0===t&&(t={}),e.call(this,a({loaders:{img:L,video:_}},t))||this}return i(t,e),t}(t),A={__proto__:null,default:w,Manager:t,VideoLoader:_,ImageLoader:L,Loader:e};for(P in A)w[P]=A[P];return w});
//# sourceMappingURL=imready.min.js.map
{
"name": "@egjs/imready",
"version": "1.1.0",
"version": "1.1.1",
"description": "This module is used to wait for the image or video to be ready.",

@@ -24,3 +24,7 @@ "main": "dist/imready.cjs.js",

"demo:deploy": "npm run build && npm run jsdoc && npm run demo:prebuild-version && npm run demo:prebuild-latest && gh-pages -d demo/ --add --remote upstream",
"release": "release-helper upstream"
"release": "release-helper upstream",
"packages": "npm run packages:update && npm run packages:build && npm run packages:publish",
"packages:update": "pvu --update=react-imready",
"packages:build": "pvu --build=react-imready",
"packages:publish": "pvu --publish=react-imready"
},

@@ -73,2 +77,3 @@ "repository": {

"print-sizes": "^0.1.0",
"pvu": "^0.4.1",
"rollup": "^1.7.3",

@@ -75,0 +80,0 @@ "rollup-plugin-node-resolve": "^4.0.1",

@@ -101,5 +101,11 @@ <p align="middle" ><img src="./demo/images/logo.png"/></p>

|---|---|---|---|---|---|
|9+(polyfill 8+)|Latest|Latest|Latest|7+|2.3+(except 3.x)|
|9+(polyfill 8+)|Latest|Latest|Latest|7+|4+(polyfill 2.2+)|
### **Use polyfill if you want to use it in a lower version browser.**
* Array.prototype.forEach
* Array.prototype.map
* Array.prototype.some
* Array.prototype.filter
## How to start developing egjs-imready?

@@ -106,0 +112,0 @@

@@ -6,2 +6,3 @@ /*

*/
import { addAutoSizer } from "../AutoSizer";
import { ImReadyLoaderOptions } from "../types";

@@ -18,4 +19,13 @@ import Loader from "./Loader";

}
public checkElement() {
if (!this.hasDataSize) {
public check() {
if (this.isSkip) {
// I'm Ready
this.onAlreadyReady(true);
return false;
}
if (this.hasDataSize) {
addAutoSizer(this.element, this.options.prefix);
this.onAlreadyPreReady();
} else {
// has not data size

@@ -26,2 +36,5 @@ this.trigger("requestChildren");

}
public checkElement() {
return true;
}
public destroy() {

@@ -28,0 +41,0 @@ this.removeAutoSizer();

@@ -35,3 +35,3 @@ /*

public check() {
if (this.isSkip || hasSkipAttribute(this.element) || !this.checkElement()) {
if (this.isSkip || !this.checkElement()) {
// I'm Ready

@@ -38,0 +38,0 @@ this.onAlreadyReady(true);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc