Socket
Socket
Sign inDemoInstall

element-resize-detector

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

element-resize-detector - npm Package Compare versions

Comparing version 1.1.11 to 1.1.12

4

dist/element-resize-detector.min.js
/*!
* element-resize-detector 1.1.11
* element-resize-detector 1.1.12
* Copyright (c) 2016 Lucas Wiener

@@ -8,2 +8,2 @@ * https://github.com/wnr/element-resize-detector

!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.elementResizeDetectorMaker=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";function d(){function a(a,b){b||(b=a,a=0),a>f?f=a:a<g&&(g=a),d[a]||(d[a]=[]),d[a].push(b),e++}function b(){for(var a=g;a<=f;a++)for(var b=d[a],c=0;c<b.length;c++){var e=b[c];e()}}function c(){return e}var d={},e=0,f=0,g=0;return{add:a,process:b,size:c}}var e=a("./utils");b.exports=function(a){function b(a,b){!o&&l&&k&&0===n.size()&&g(),n.add(a,b)}function c(){for(o=!0;n.size();){var a=n;n=d(),a.process()}o=!1}function f(a){o||(void 0===a&&(a=k),m&&(h(m),m=null),a?g():c())}function g(){m=i(c)}function h(a){var b=clearTimeout;return b(a)}function i(a){var b=function(a){return setTimeout(a,0)};return b(a)}a=a||{};var j=a.reporter,k=e.getOption(a,"async",!0),l=e.getOption(a,"auto",!0);l&&!k&&(j&&j.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),k=!0);var m,n=d(),o=!1;return{add:b,force:f}}},{"./utils":2}],2:[function(a,b,c){"use strict";function d(a,b,c){var d=a[b];return void 0!==d&&null!==d||void 0===c?d:c}var e=b.exports={};e.getOption=d},{}],3:[function(a,b,c){"use strict";var d=b.exports={};d.isIE=function(a){function b(){var a=navigator.userAgent.toLowerCase();return a.indexOf("msie")!==-1||a.indexOf("trident")!==-1||a.indexOf(" edge/")!==-1}if(!b())return!1;if(!a)return!0;var c=function(){var a,b=3,c=document.createElement("div"),d=c.getElementsByTagName("i");do c.innerHTML="<!--[if gt IE "+ ++b+"]><i></i><![endif]-->";while(d[0]);return b>4?b:a}();return a===c},d.isLegacyOpera=function(){return!!window.opera}},{}],4:[function(a,b,c){"use strict";var d=b.exports={};d.forEach=function(a,b){for(var c=0;c<a.length;c++){var d=b(a[c]);if(d)return d}}},{}],5:[function(a,b,c){"use strict";var d=a("../browser-detector");b.exports=function(a){function b(a,b){function c(){b(a)}if(!e(a))throw new Error("Element is not detectable by this strategy.");if(d.isIE(8))i(a).object={proxy:c},a.attachEvent("onresize",c);else{var f=e(a);f.contentDocument.defaultView.addEventListener("resize",c)}}function c(a,b,c){function e(a,b){function c(){function c(){if("static"===j.position){a.style.position="relative";var b=function(a,b,c,d){function e(a){return a.replace(/[^-\d\.]/g,"")}var f=c[d];"auto"!==f&&"0"!==e(f)&&(a.warn("An element that is positioned static has style."+d+"="+f+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+d+" will be set to 0. Element: ",b),b.style[d]=0)};b(g,a,j,"top"),b(g,a,j,"right"),b(g,a,j,"bottom"),b(g,a,j,"left")}}function h(){function d(a,b){return a.contentDocument?void b(a.contentDocument):void setTimeout(function(){d(a,b)},100)}f||c();var e=this;d(e,function(c){b(a)})}""!==j.position&&(c(j),f=!0);var k=document.createElement("object");k.style.cssText=e,k.tabIndex=-1,k.type="text/html",k.onload=h,d.isIE()||(k.data="about:blank"),a.appendChild(k),i(a).object=k,d.isIE()&&(k.data="about:blank")}var e="display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; padding: 0; margin: 0; opacity: 0; z-index: -1000; pointer-events: none;",f=!1,j=window.getComputedStyle(a),k=a.offsetWidth,l=a.offsetHeight;i(a).startSize={width:k,height:l},h?h.add(c):c()}c||(c=b,b=a,a=null),a=a||{};a.debug;d.isIE(8)?c(b):e(b,c)}function e(a){return i(a).object}function f(a){d.isIE(8)?a.detachEvent("onresize",i(a).object.proxy):a.removeChild(e(a)),delete i(a).object}a=a||{};var g=a.reporter,h=a.batchProcessor,i=a.stateHandler.getState;if(!g)throw new Error("Missing required dependency: reporter.");return{makeDetectable:c,addListener:b,uninstall:f}}},{"../browser-detector":3}],6:[function(a,b,c){"use strict";var d=a("../collection-utils").forEach;b.exports=function(a){function b(){var a=500,b=500,c=document.createElement("div");c.style.cssText="position: absolute; width: "+2*a+"px; height: "+2*b+"px; visibility: hidden; margin: 0; padding: 0;";var d=document.createElement("div");d.style.cssText="position: absolute; width: "+a+"px; height: "+b+"px; overflow: scroll; visibility: none; top: "+3*-a+"px; left: "+3*-b+"px; visibility: hidden; margin: 0; padding: 0;",d.appendChild(c),document.body.insertBefore(d,document.body.firstChild);var e=a-d.clientWidth,f=b-d.clientHeight;return document.body.removeChild(d),{width:e,height:f}}function c(a,b){function c(b,c){c=c||function(a){document.head.appendChild(a)};var d=document.createElement("style");return d.innerHTML=b,d.id=a,c(d),d}if(!document.getElementById(a)){var d=b+"_animation",e=b+"_animation_active",f="/* Created by the element-resize-detector library. */\n";f+="."+b+" > div::-webkit-scrollbar { display: none; }\n\n",f+="."+e+" { -webkit-animation-duration: 0.1s; animation-duration: 0.1s; -webkit-animation-name: "+d+"; animation-name: "+d+"; }\n",f+="@-webkit-keyframes "+d+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }\n",f+="@keyframes "+d+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }",c(f)}}function e(a){a.className+=" "+s+"_animation_active"}function f(a,b,c){if(a.addEventListener)a.addEventListener(b,c);else{if(!a.attachEvent)return m.error("[scroll] Don't know how to add event listeners.");a.attachEvent("on"+b,c)}}function g(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c);else{if(!a.detachEvent)return m.error("[scroll] Don't know how to remove event listeners.");a.detachEvent("on"+b,c)}}function h(a){return o(a).container.childNodes[0].childNodes[0].childNodes[0]}function i(a){return o(a).container.childNodes[0].childNodes[0].childNodes[1]}function j(a,b){var c=o(a).listeners;if(!c.push)throw new Error("Cannot add listener to an element that is not detectable.");o(a).listeners.push(b)}function k(a,b,c){function g(){if(a.debug){var c=Array.prototype.slice.call(arguments);if(c.unshift(p.get(b),"Scroll: "),m.log.apply)m.log.apply(null,c);else for(var d=0;d<c.length;d++)m.log(c[d])}}function j(a){function b(a){return a===a.ownerDocument.body||a.ownerDocument.body.contains(a)}return!b(a)}function k(a){var b=o(a).container.childNodes[0];return getComputedStyle(b).width.indexOf("px")===-1}function l(){var a=getComputedStyle(b),c={};return c.position=a.position,c.width=b.offsetWidth,c.height=b.offsetHeight,c.top=a.top,c.right=a.right,c.bottom=a.bottom,c.left=a.left,c.widthCSS=a.width,c.heightCSS=a.height,c}function r(){var a=l();o(b).startSize={width:a.width,height:a.height},g("Element start size",o(b).startSize)}function t(){o(b).listeners=[]}function u(){if(g("storeStyle invoked."),!o(b))return void g("Aborting because element has been uninstalled");var a=l();o(b).style=a}function v(a,b,c){o(a).lastWidth=b,o(a).lastHeight=c}function w(a){return h(a).childNodes[0]}function x(){return 2*q.width+1}function y(){return 2*q.height+1}function z(a){return a+10+x()}function A(a){return a+10+y()}function B(a){return 2*a+x()}function C(a){return 2*a+y()}function D(a,b,c){var d=h(a),e=i(a),f=z(b),g=A(c),j=B(b),k=C(c);d.scrollLeft=f,d.scrollTop=g,e.scrollLeft=j,e.scrollTop=k}function E(){var a=o(b).container;if(!a){a=document.createElement("div"),a.className=s,a.style.cssText="visibility: hidden; display: inline; width: 0px; height: 0px; z-index: -1; overflow: hidden; margin: 0; padding: 0;",o(b).container=a,e(a),b.appendChild(a);var c=function(){o(b).onRendered&&o(b).onRendered()};f(a,"animationstart",c),o(b).onAnimationStart=c}return a}function F(){function a(){var a=o(b).style;if("static"===a.position){b.style.position="relative";var c=function(a,b,c,d){function e(a){return a.replace(/[^-\d\.]/g,"")}var f=c[d];"auto"!==f&&"0"!==e(f)&&(a.warn("An element that is positioned static has style."+d+"="+f+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+d+" will be set to 0. Element: ",b),b.style[d]=0)};c(m,b,a,"top"),c(m,b,a,"right"),c(m,b,a,"bottom"),c(m,b,a,"left")}}function c(a,b,c,d){return a=a?a+"px":"0",b=b?b+"px":"0",c=c?c+"px":"0",d=d?d+"px":"0","left: "+a+"; top: "+b+"; right: "+d+"; bottom: "+c+";"}function d(){o(b).onExpand&&o(b).onExpand()}function e(){o(b).onShrink&&o(b).onShrink()}if(g("Injecting elements"),!o(b))return void g("Aborting because element has been uninstalled");a();var h=o(b).container;h||(h=E());var i=q.width,j=q.height,k="position: absolute; flex: none; overflow: hidden; z-index: -1; visibility: hidden; width: 100%; height: 100%; left: 0px; top: 0px;",l="position: absolute; flex: none; overflow: hidden; z-index: -1; visibility: hidden; "+c(-(1+i),-(1+j),-j,-i),n="position: absolute; flex: none; overflow: scroll; z-index: -1; visibility: hidden; width: 100%; height: 100%;",p="position: absolute; flex: none; overflow: scroll; z-index: -1; visibility: hidden; width: 100%; height: 100%;",r="position: absolute; left: 0; top: 0;",t="position: absolute; width: 200%; height: 200%;",u=document.createElement("div"),v=document.createElement("div"),w=document.createElement("div"),x=document.createElement("div"),y=document.createElement("div"),z=document.createElement("div");u.dir="ltr",u.style.cssText=k,u.className=s,v.className=s,v.style.cssText=l,w.style.cssText=n,x.style.cssText=r,y.style.cssText=p,z.style.cssText=t,w.appendChild(x),y.appendChild(z),v.appendChild(w),v.appendChild(y),u.appendChild(v),h.appendChild(u),f(w,"scroll",d),f(y,"scroll",e),o(b).onExpandScroll=d,o(b).onShrinkScroll=e}function G(){function c(a,b,c){var d=w(a),e=z(b),f=A(c);d.style.width=e+"px",d.style.height=f+"px"}function e(d){var e=b.offsetWidth,h=b.offsetHeight;g("Storing current size",e,h),v(b,e,h),n.add(0,function(){if(!o(b))return void g("Aborting because element has been uninstalled");if(!f())return void g("Aborting because element container has not been initialized");if(a.debug){var d=b.offsetWidth,i=b.offsetHeight;d===e&&i===h||m.warn(p.get(b),"Scroll: Size changed before updating detector elements.")}c(b,e,h)}),n.add(1,function(){return o(b)?f()?void D(b,e,h):void g("Aborting because element container has not been initialized"):void g("Aborting because element has been uninstalled")}),d&&n.add(2,function(){return o(b)?f()?void d():void g("Aborting because element container has not been initialized"):void g("Aborting because element has been uninstalled")})}function f(){return!!o(b).container}function j(){function a(){return void 0===o(b).lastNotifiedWidth}g("notifyListenersIfNeeded invoked");var c=o(b);return a()&&c.lastWidth===c.startSize.width&&c.lastHeight===c.startSize.height?g("Not notifying: Size is the same as the start size, and there has been no notification yet."):c.lastWidth===c.lastNotifiedWidth&&c.lastHeight===c.lastNotifiedHeight?g("Not notifying: Size already notified"):(g("Current size not notified, notifying..."),c.lastNotifiedWidth=c.lastWidth,c.lastNotifiedHeight=c.lastHeight,void d(o(b).listeners,function(a){a(b)}))}function l(){if(g("startanimation triggered."),k(b))return void g("Ignoring since element is still unrendered...");g("Element rendered.");var a=h(b),c=i(b);0!==a.scrollLeft&&0!==a.scrollTop&&0!==c.scrollLeft&&0!==c.scrollTop||(g("Scrollbars out of sync. Updating detector elements..."),e(j))}function q(){if(g("Scroll detected."),k(b))return void g("Scroll event fired while unrendered. Ignoring...");var a=b.offsetWidth,c=b.offsetHeight;a!==b.lastWidth||c!==b.lastHeight?(g("Element size changed."),e(j)):g("Element size has not changed ("+a+"x"+c+").")}if(g("registerListenersAndPositionElements invoked."),!o(b))return void g("Aborting because element has been uninstalled");o(b).onRendered=l,o(b).onExpand=q,o(b).onShrink=q;var r=o(b).style;c(b,r.width,r.height)}function H(){if(g("finalizeDomMutation invoked."),!o(b))return void g("Aborting because element has been uninstalled");var a=o(b).style;v(b,a.width,a.height),D(b,a.width,a.height)}function I(){c(b)}function J(){g("Installing..."),t(),r(),n.add(0,u),n.add(1,F),n.add(2,G),n.add(3,H),n.add(4,I)}c||(c=b,b=a,a=null),a=a||{},g("Making detectable..."),j(b)?(g("Element is detached"),E(),g("Waiting until element is attached..."),o(b).onRendered=function(){g("Element is now attached"),J()}):J()}function l(a){var b=o(a);b&&(b.onExpandScroll&&g(h(a),"scroll",b.onExpandScroll),b.onShrinkScroll&&g(i(a),"scroll",b.onShrinkScroll),b.onAnimationStart&&g(b.container,"animationstart",b.onAnimationStart),b.container&&a.removeChild(b.container))}a=a||{};var m=a.reporter,n=a.batchProcessor,o=a.stateHandler.getState,p=(a.stateHandler.hasState,a.idHandler);if(!n)throw new Error("Missing required dependency: batchProcessor");if(!m)throw new Error("Missing required dependency: reporter.");var q=b(),r="erd_scroll_detection_scrollbar_style",s="erd_scroll_detection_container";return c(r,s),{makeDetectable:k,addListener:j,uninstall:l}}},{"../collection-utils":4}],7:[function(a,b,c){"use strict";function d(a){return Array.isArray(a)||void 0!==a.length}function e(a){if(Array.isArray(a))return a;var b=[];return h(a,function(a){b.push(a)}),b}function f(a){return a&&1===a.nodeType}function g(a,b,c){var d=a[b];return void 0!==d&&null!==d||void 0===c?d:c}var h=a("./collection-utils").forEach,i=a("./element-utils"),j=a("./listener-handler"),k=a("./id-generator"),l=a("./id-handler"),m=a("./reporter"),n=a("./browser-detector"),o=a("batch-processor"),p=a("./state-handler"),q=a("./detection-strategy/object.js"),r=a("./detection-strategy/scroll.js");b.exports=function(a){function b(a,b,c){function i(a){var b=A.get(a);h(b,function(b){b(a)})}function j(a,b,c){A.add(b,c),a&&c(b)}if(c||(c=b,b=a,a={}),!b)throw new Error("At least one element required.");if(!c)throw new Error("Listener required.");if(f(b))b=[b];else{if(!d(b))return v.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");b=e(b)}var k=0,l=g(a,"callOnAdd",y.callOnAdd),m=g(a,"onReady",function(){}),n=g(a,"debug",y.debug);h(b,function(a){p.getState(a)||(p.initState(a),s.set(a));var d=s.get(a);return n&&v.log("Attaching listener to element",d,a),B.isDetectable(a)?(n&&v.log(d,"Already detecable, adding listener."),j(l,a,c),void k++):(n&&v.log(d,"Not detectable."),B.isBusy(a)?(n&&v.log(d,"System busy making it detectable"),j(l,a,c),E[d]=E[d]||[],void E[d].push(function(){k++,k===b.length&&m()})):(n&&v.log(d,"Making detectable..."),B.markBusy(a,!0),z.makeDetectable({debug:n},a,function(a){if(n&&v.log(d,"onElementDetectable"),p.getState(a)){B.markAsDetectable(a),B.markBusy(a,!1),z.addListener(a,i),j(l,a,c);var e=p.getState(a);if(e&&e.startSize){var f=a.offsetWidth,g=a.offsetHeight;e.startSize.width===f&&e.startSize.height===g||i(a)}E[d]&&h(E[d],function(a){a()})}else n&&v.log(d,"Element uninstalled before being detectable.");delete E[d],k++,k===b.length&&m()})))}),k===b.length&&m()}function c(a){if(!a)return v.error("At least one element is required.");if(f(a))a=[a];else{if(!d(a))return v.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");a=e(a)}h(a,function(a){A.removeAllListeners(a),z.uninstall(a),p.cleanState(a)})}a=a||{};var s;if(a.idHandler)s={get:function(b){return a.idHandler.get(b,!0)},set:a.idHandler.set};else{var t=k(),u=l({idGenerator:t,stateHandler:p});s=u}var v=a.reporter;if(!v){var w=v===!1;v=m(w)}var x=g(a,"batchProcessor",o({reporter:v})),y={};y.callOnAdd=!!g(a,"callOnAdd",!0),y.debug=!!g(a,"debug",!1);var z,A=j(s),B=i({stateHandler:p}),C=g(a,"strategy","object"),D={reporter:v,batchProcessor:x,stateHandler:p,idHandler:s};if("scroll"===C&&(n.isLegacyOpera()?(v.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),C="object"):n.isIE(9)&&(v.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),C="object")),"scroll"===C)z=r(D);else{if("object"!==C)throw new Error("Invalid strategy name: "+C);z=q(D)}var E={};return{listenTo:b,removeListener:A.removeListener,removeAllListeners:A.removeAllListeners,uninstall:c}}},{"./browser-detector":3,"./collection-utils":4,"./detection-strategy/object.js":5,"./detection-strategy/scroll.js":6,"./element-utils":8,"./id-generator":9,"./id-handler":10,"./listener-handler":11,"./reporter":12,"./state-handler":13,"batch-processor":1}],8:[function(a,b,c){"use strict";b.exports=function(a){function b(a){var b=f(a);return b&&!!b.isDetectable}function c(a){f(a).isDetectable=!0}function d(a){return!!f(a).busy}function e(a,b){f(a).busy=!!b}var f=a.stateHandler.getState;return{isDetectable:b,markAsDetectable:c,isBusy:d,markBusy:e}}},{}],9:[function(a,b,c){"use strict";b.exports=function(){function a(){return b++}var b=1;return{generate:a}}},{}],10:[function(a,b,c){"use strict";b.exports=function(a){function b(a){var b=e(a);return b&&void 0!==b.id?b.id:null}function c(a){var b=e(a);if(!b)throw new Error("setId required the element to have a resize detection state.");var c=d.generate();return b.id=c,c}var d=a.idGenerator,e=a.stateHandler.getState;return{get:b,set:c}}},{}],11:[function(a,b,c){"use strict";b.exports=function(a){function b(b){var c=a.get(b);return void 0===c?[]:f[c]||[]}function c(b,c){var d=a.get(b);f[d]||(f[d]=[]),f[d].push(c)}function d(a,c){for(var d=b(a),e=0,f=d.length;e<f;++e)if(d[e]===c){d.splice(e,1);break}}function e(a){var c=b(a);c&&(c.length=0)}var f={};return{get:b,add:c,removeListener:d,removeAllListeners:e}}},{}],12:[function(a,b,c){"use strict";b.exports=function(a){function b(){}var c={log:b,warn:b,error:b};if(!a&&window.console){var d=function(a,b){a[b]=function(){var a=console[b];if(a.apply)a.apply(console,arguments);else for(var c=0;c<arguments.length;c++)a(arguments[c])}};d(c,"log"),d(c,"warn"),d(c,"error")}return c}},{}],13:[function(a,b,c){"use strict";function d(a){return a[g]={},e(a)}function e(a){return a[g]}function f(a){delete a[g]}var g="_erd";b.exports={initState:d,getState:e,cleanState:f}},{}]},{},[7])(7)});
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.elementResizeDetectorMaker=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";function d(){function a(a,b){b||(b=a,a=0),a>f?f=a:a<g&&(g=a),d[a]||(d[a]=[]),d[a].push(b),e++}function b(){for(var a=g;a<=f;a++)for(var b=d[a],c=0;c<b.length;c++){var e=b[c];e()}}function c(){return e}var d={},e=0,f=0,g=0;return{add:a,process:b,size:c}}var e=a("./utils");b.exports=function(a){function b(a,b){!o&&l&&k&&0===n.size()&&g(),n.add(a,b)}function c(){for(o=!0;n.size();){var a=n;n=d(),a.process()}o=!1}function f(a){o||(void 0===a&&(a=k),m&&(h(m),m=null),a?g():c())}function g(){m=i(c)}function h(a){var b=clearTimeout;return b(a)}function i(a){var b=function(a){return setTimeout(a,0)};return b(a)}a=a||{};var j=a.reporter,k=e.getOption(a,"async",!0),l=e.getOption(a,"auto",!0);l&&!k&&(j&&j.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),k=!0);var m,n=d(),o=!1;return{add:b,force:f}}},{"./utils":2}],2:[function(a,b,c){"use strict";function d(a,b,c){var d=a[b];return void 0!==d&&null!==d||void 0===c?d:c}var e=b.exports={};e.getOption=d},{}],3:[function(a,b,c){"use strict";var d=b.exports={};d.isIE=function(a){function b(){var a=navigator.userAgent.toLowerCase();return a.indexOf("msie")!==-1||a.indexOf("trident")!==-1||a.indexOf(" edge/")!==-1}if(!b())return!1;if(!a)return!0;var c=function(){var a,b=3,c=document.createElement("div"),d=c.getElementsByTagName("i");do c.innerHTML="<!--[if gt IE "+ ++b+"]><i></i><![endif]-->";while(d[0]);return b>4?b:a}();return a===c},d.isLegacyOpera=function(){return!!window.opera}},{}],4:[function(a,b,c){"use strict";var d=b.exports={};d.forEach=function(a,b){for(var c=0;c<a.length;c++){var d=b(a[c]);if(d)return d}}},{}],5:[function(a,b,c){"use strict";var d=a("../browser-detector");b.exports=function(a){function b(a,b){function c(){b(a)}if(!e(a))throw new Error("Element is not detectable by this strategy.");if(d.isIE(8))i(a).object={proxy:c},a.attachEvent("onresize",c);else{var f=e(a);f.contentDocument.defaultView.addEventListener("resize",c)}}function c(a,b,c){function e(a,b){function c(){function c(){if("static"===j.position){a.style.position="relative";var b=function(a,b,c,d){function e(a){return a.replace(/[^-\d\.]/g,"")}var f=c[d];"auto"!==f&&"0"!==e(f)&&(a.warn("An element that is positioned static has style."+d+"="+f+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+d+" will be set to 0. Element: ",b),b.style[d]=0)};b(g,a,j,"top"),b(g,a,j,"right"),b(g,a,j,"bottom"),b(g,a,j,"left")}}function h(){function d(a,b){return a.contentDocument?void b(a.contentDocument):void setTimeout(function(){d(a,b)},100)}f||c();var e=this;d(e,function(c){b(a)})}""!==j.position&&(c(j),f=!0);var k=document.createElement("object");k.style.cssText=e,k.tabIndex=-1,k.type="text/html",k.onload=h,d.isIE()||(k.data="about:blank"),a.appendChild(k),i(a).object=k,d.isIE()&&(k.data="about:blank")}var e="display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; padding: 0; margin: 0; opacity: 0; z-index: -1000; pointer-events: none;",f=!1,j=window.getComputedStyle(a),k=a.offsetWidth,l=a.offsetHeight;i(a).startSize={width:k,height:l},h?h.add(c):c()}c||(c=b,b=a,a=null),a=a||{};a.debug;d.isIE(8)?c(b):e(b,c)}function e(a){return i(a).object}function f(a){d.isIE(8)?a.detachEvent("onresize",i(a).object.proxy):a.removeChild(e(a)),delete i(a).object}a=a||{};var g=a.reporter,h=a.batchProcessor,i=a.stateHandler.getState;if(!g)throw new Error("Missing required dependency: reporter.");return{makeDetectable:c,addListener:b,uninstall:f}}},{"../browser-detector":3}],6:[function(a,b,c){"use strict";var d=a("../collection-utils").forEach;b.exports=function(a){function b(){var a=500,b=500,c=document.createElement("div");c.style.cssText="position: absolute; width: "+2*a+"px; height: "+2*b+"px; visibility: hidden; margin: 0; padding: 0;";var d=document.createElement("div");d.style.cssText="position: absolute; width: "+a+"px; height: "+b+"px; overflow: scroll; visibility: none; top: "+3*-a+"px; left: "+3*-b+"px; visibility: hidden; margin: 0; padding: 0;",d.appendChild(c),document.body.insertBefore(d,document.body.firstChild);var e=a-d.clientWidth,f=b-d.clientHeight;return document.body.removeChild(d),{width:e,height:f}}function c(a,b){function c(b,c){c=c||function(a){document.head.appendChild(a)};var d=document.createElement("style");return d.innerHTML=b,d.id=a,c(d),d}if(!document.getElementById(a)){var d=b+"_animation",e=b+"_animation_active",f="/* Created by the element-resize-detector library. */\n";f+="."+b+" > div::-webkit-scrollbar { display: none; }\n\n",f+="."+e+" { -webkit-animation-duration: 0.1s; animation-duration: 0.1s; -webkit-animation-name: "+d+"; animation-name: "+d+"; }\n",f+="@-webkit-keyframes "+d+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }\n",f+="@keyframes "+d+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }",c(f)}}function e(a){a.className+=" "+s+"_animation_active"}function f(a,b,c){if(a.addEventListener)a.addEventListener(b,c);else{if(!a.attachEvent)return m.error("[scroll] Don't know how to add event listeners.");a.attachEvent("on"+b,c)}}function g(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c);else{if(!a.detachEvent)return m.error("[scroll] Don't know how to remove event listeners.");a.detachEvent("on"+b,c)}}function h(a){return o(a).container.childNodes[0].childNodes[0].childNodes[0]}function i(a){return o(a).container.childNodes[0].childNodes[0].childNodes[1]}function j(a,b){var c=o(a).listeners;if(!c.push)throw new Error("Cannot add listener to an element that is not detectable.");o(a).listeners.push(b)}function k(a,b,c){function g(){if(a.debug){var c=Array.prototype.slice.call(arguments);if(c.unshift(p.get(b),"Scroll: "),m.log.apply)m.log.apply(null,c);else for(var d=0;d<c.length;d++)m.log(c[d])}}function j(a){function b(a){return a===a.ownerDocument.body||a.ownerDocument.body.contains(a)}return!b(a)||null===getComputedStyle(a)}function k(a){var b=o(a).container.childNodes[0],c=getComputedStyle(b);return!c.width||c.width.indexOf("px")===-1}function l(){var a=getComputedStyle(b),c={};return c.position=a.position,c.width=b.offsetWidth,c.height=b.offsetHeight,c.top=a.top,c.right=a.right,c.bottom=a.bottom,c.left=a.left,c.widthCSS=a.width,c.heightCSS=a.height,c}function r(){var a=l();o(b).startSize={width:a.width,height:a.height},g("Element start size",o(b).startSize)}function t(){o(b).listeners=[]}function u(){if(g("storeStyle invoked."),!o(b))return void g("Aborting because element has been uninstalled");var a=l();o(b).style=a}function v(a,b,c){o(a).lastWidth=b,o(a).lastHeight=c}function w(a){return h(a).childNodes[0]}function x(){return 2*q.width+1}function y(){return 2*q.height+1}function z(a){return a+10+x()}function A(a){return a+10+y()}function B(a){return 2*a+x()}function C(a){return 2*a+y()}function D(a,b,c){var d=h(a),e=i(a),f=z(b),g=A(c),j=B(b),k=C(c);d.scrollLeft=f,d.scrollTop=g,e.scrollLeft=j,e.scrollTop=k}function E(){var a=o(b).container;if(!a){a=document.createElement("div"),a.className=s,a.style.cssText="visibility: hidden; display: inline; width: 0px; height: 0px; z-index: -1; overflow: hidden; margin: 0; padding: 0;",o(b).container=a,e(a),b.appendChild(a);var c=function(){o(b).onRendered&&o(b).onRendered()};f(a,"animationstart",c),o(b).onAnimationStart=c}return a}function F(){function a(){var a=o(b).style;if("static"===a.position){b.style.position="relative";var c=function(a,b,c,d){function e(a){return a.replace(/[^-\d\.]/g,"")}var f=c[d];"auto"!==f&&"0"!==e(f)&&(a.warn("An element that is positioned static has style."+d+"="+f+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+d+" will be set to 0. Element: ",b),b.style[d]=0)};c(m,b,a,"top"),c(m,b,a,"right"),c(m,b,a,"bottom"),c(m,b,a,"left")}}function c(a,b,c,d){return a=a?a+"px":"0",b=b?b+"px":"0",c=c?c+"px":"0",d=d?d+"px":"0","left: "+a+"; top: "+b+"; right: "+d+"; bottom: "+c+";"}function d(){o(b).onExpand&&o(b).onExpand()}function e(){o(b).onShrink&&o(b).onShrink()}if(g("Injecting elements"),!o(b))return void g("Aborting because element has been uninstalled");a();var h=o(b).container;h||(h=E());var i=q.width,j=q.height,k="position: absolute; flex: none; overflow: hidden; z-index: -1; visibility: hidden; width: 100%; height: 100%; left: 0px; top: 0px;",l="position: absolute; flex: none; overflow: hidden; z-index: -1; visibility: hidden; "+c(-(1+i),-(1+j),-j,-i),n="position: absolute; flex: none; overflow: scroll; z-index: -1; visibility: hidden; width: 100%; height: 100%;",p="position: absolute; flex: none; overflow: scroll; z-index: -1; visibility: hidden; width: 100%; height: 100%;",r="position: absolute; left: 0; top: 0;",t="position: absolute; width: 200%; height: 200%;",u=document.createElement("div"),v=document.createElement("div"),w=document.createElement("div"),x=document.createElement("div"),y=document.createElement("div"),z=document.createElement("div");u.dir="ltr",u.style.cssText=k,u.className=s,v.className=s,v.style.cssText=l,w.style.cssText=n,x.style.cssText=r,y.style.cssText=p,z.style.cssText=t,w.appendChild(x),y.appendChild(z),v.appendChild(w),v.appendChild(y),u.appendChild(v),h.appendChild(u),f(w,"scroll",d),f(y,"scroll",e),o(b).onExpandScroll=d,o(b).onShrinkScroll=e}function G(){function c(a,b,c){var d=w(a),e=z(b),f=A(c);d.style.width=e+"px",d.style.height=f+"px"}function e(d){var e=b.offsetWidth,h=b.offsetHeight;g("Storing current size",e,h),v(b,e,h),n.add(0,function(){if(!o(b))return void g("Aborting because element has been uninstalled");if(!f())return void g("Aborting because element container has not been initialized");if(a.debug){var d=b.offsetWidth,i=b.offsetHeight;d===e&&i===h||m.warn(p.get(b),"Scroll: Size changed before updating detector elements.")}c(b,e,h)}),n.add(1,function(){return o(b)?f()?void D(b,e,h):void g("Aborting because element container has not been initialized"):void g("Aborting because element has been uninstalled")}),d&&n.add(2,function(){return o(b)?f()?void d():void g("Aborting because element container has not been initialized"):void g("Aborting because element has been uninstalled")})}function f(){return!!o(b).container}function j(){function a(){return void 0===o(b).lastNotifiedWidth}g("notifyListenersIfNeeded invoked");var c=o(b);return a()&&c.lastWidth===c.startSize.width&&c.lastHeight===c.startSize.height?g("Not notifying: Size is the same as the start size, and there has been no notification yet."):c.lastWidth===c.lastNotifiedWidth&&c.lastHeight===c.lastNotifiedHeight?g("Not notifying: Size already notified"):(g("Current size not notified, notifying..."),c.lastNotifiedWidth=c.lastWidth,c.lastNotifiedHeight=c.lastHeight,void d(o(b).listeners,function(a){a(b)}))}function l(){if(g("startanimation triggered."),k(b))return void g("Ignoring since element is still unrendered...");g("Element rendered.");var a=h(b),c=i(b);0!==a.scrollLeft&&0!==a.scrollTop&&0!==c.scrollLeft&&0!==c.scrollTop||(g("Scrollbars out of sync. Updating detector elements..."),e(j))}function q(){if(g("Scroll detected."),k(b))return void g("Scroll event fired while unrendered. Ignoring...");var a=b.offsetWidth,c=b.offsetHeight;a!==b.lastWidth||c!==b.lastHeight?(g("Element size changed."),e(j)):g("Element size has not changed ("+a+"x"+c+").")}if(g("registerListenersAndPositionElements invoked."),!o(b))return void g("Aborting because element has been uninstalled");o(b).onRendered=l,o(b).onExpand=q,o(b).onShrink=q;var r=o(b).style;c(b,r.width,r.height)}function H(){if(g("finalizeDomMutation invoked."),!o(b))return void g("Aborting because element has been uninstalled");var a=o(b).style;v(b,a.width,a.height),D(b,a.width,a.height)}function I(){c(b)}function J(){g("Installing..."),t(),r(),n.add(0,u),n.add(1,F),n.add(2,G),n.add(3,H),n.add(4,I)}c||(c=b,b=a,a=null),a=a||{},g("Making detectable..."),j(b)?(g("Element is detached"),E(),g("Waiting until element is attached..."),o(b).onRendered=function(){g("Element is now attached"),J()}):J()}function l(a){var b=o(a);b&&(b.onExpandScroll&&g(h(a),"scroll",b.onExpandScroll),b.onShrinkScroll&&g(i(a),"scroll",b.onShrinkScroll),b.onAnimationStart&&g(b.container,"animationstart",b.onAnimationStart),b.container&&a.removeChild(b.container))}a=a||{};var m=a.reporter,n=a.batchProcessor,o=a.stateHandler.getState,p=(a.stateHandler.hasState,a.idHandler);if(!n)throw new Error("Missing required dependency: batchProcessor");if(!m)throw new Error("Missing required dependency: reporter.");var q=b(),r="erd_scroll_detection_scrollbar_style",s="erd_scroll_detection_container";return c(r,s),{makeDetectable:k,addListener:j,uninstall:l}}},{"../collection-utils":4}],7:[function(a,b,c){"use strict";function d(a){return Array.isArray(a)||void 0!==a.length}function e(a){if(Array.isArray(a))return a;var b=[];return h(a,function(a){b.push(a)}),b}function f(a){return a&&1===a.nodeType}function g(a,b,c){var d=a[b];return void 0!==d&&null!==d||void 0===c?d:c}var h=a("./collection-utils").forEach,i=a("./element-utils"),j=a("./listener-handler"),k=a("./id-generator"),l=a("./id-handler"),m=a("./reporter"),n=a("./browser-detector"),o=a("batch-processor"),p=a("./state-handler"),q=a("./detection-strategy/object.js"),r=a("./detection-strategy/scroll.js");b.exports=function(a){function b(a,b,c){function i(a){var b=A.get(a);h(b,function(b){b(a)})}function j(a,b,c){A.add(b,c),a&&c(b)}if(c||(c=b,b=a,a={}),!b)throw new Error("At least one element required.");if(!c)throw new Error("Listener required.");if(f(b))b=[b];else{if(!d(b))return v.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");b=e(b)}var k=0,l=g(a,"callOnAdd",y.callOnAdd),m=g(a,"onReady",function(){}),n=g(a,"debug",y.debug);h(b,function(a){p.getState(a)||(p.initState(a),s.set(a));var d=s.get(a);return n&&v.log("Attaching listener to element",d,a),B.isDetectable(a)?(n&&v.log(d,"Already detecable, adding listener."),j(l,a,c),void k++):(n&&v.log(d,"Not detectable."),B.isBusy(a)?(n&&v.log(d,"System busy making it detectable"),j(l,a,c),E[d]=E[d]||[],void E[d].push(function(){k++,k===b.length&&m()})):(n&&v.log(d,"Making detectable..."),B.markBusy(a,!0),z.makeDetectable({debug:n},a,function(a){if(n&&v.log(d,"onElementDetectable"),p.getState(a)){B.markAsDetectable(a),B.markBusy(a,!1),z.addListener(a,i),j(l,a,c);var e=p.getState(a);if(e&&e.startSize){var f=a.offsetWidth,g=a.offsetHeight;e.startSize.width===f&&e.startSize.height===g||i(a)}E[d]&&h(E[d],function(a){a()})}else n&&v.log(d,"Element uninstalled before being detectable.");delete E[d],k++,k===b.length&&m()})))}),k===b.length&&m()}function c(a){if(!a)return v.error("At least one element is required.");if(f(a))a=[a];else{if(!d(a))return v.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");a=e(a)}h(a,function(a){A.removeAllListeners(a),z.uninstall(a),p.cleanState(a)})}a=a||{};var s;if(a.idHandler)s={get:function(b){return a.idHandler.get(b,!0)},set:a.idHandler.set};else{var t=k(),u=l({idGenerator:t,stateHandler:p});s=u}var v=a.reporter;if(!v){var w=v===!1;v=m(w)}var x=g(a,"batchProcessor",o({reporter:v})),y={};y.callOnAdd=!!g(a,"callOnAdd",!0),y.debug=!!g(a,"debug",!1);var z,A=j(s),B=i({stateHandler:p}),C=g(a,"strategy","object"),D={reporter:v,batchProcessor:x,stateHandler:p,idHandler:s};if("scroll"===C&&(n.isLegacyOpera()?(v.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),C="object"):n.isIE(9)&&(v.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),C="object")),"scroll"===C)z=r(D);else{if("object"!==C)throw new Error("Invalid strategy name: "+C);z=q(D)}var E={};return{listenTo:b,removeListener:A.removeListener,removeAllListeners:A.removeAllListeners,uninstall:c}}},{"./browser-detector":3,"./collection-utils":4,"./detection-strategy/object.js":5,"./detection-strategy/scroll.js":6,"./element-utils":8,"./id-generator":9,"./id-handler":10,"./listener-handler":11,"./reporter":12,"./state-handler":13,"batch-processor":1}],8:[function(a,b,c){"use strict";b.exports=function(a){function b(a){var b=f(a);return b&&!!b.isDetectable}function c(a){f(a).isDetectable=!0}function d(a){return!!f(a).busy}function e(a,b){f(a).busy=!!b}var f=a.stateHandler.getState;return{isDetectable:b,markAsDetectable:c,isBusy:d,markBusy:e}}},{}],9:[function(a,b,c){"use strict";b.exports=function(){function a(){return b++}var b=1;return{generate:a}}},{}],10:[function(a,b,c){"use strict";b.exports=function(a){function b(a){var b=e(a);return b&&void 0!==b.id?b.id:null}function c(a){var b=e(a);if(!b)throw new Error("setId required the element to have a resize detection state.");var c=d.generate();return b.id=c,c}var d=a.idGenerator,e=a.stateHandler.getState;return{get:b,set:c}}},{}],11:[function(a,b,c){"use strict";b.exports=function(a){function b(b){var c=a.get(b);return void 0===c?[]:f[c]||[]}function c(b,c){var d=a.get(b);f[d]||(f[d]=[]),f[d].push(c)}function d(a,c){for(var d=b(a),e=0,f=d.length;e<f;++e)if(d[e]===c){d.splice(e,1);break}}function e(a){var c=b(a);c&&(c.length=0)}var f={};return{get:b,add:c,removeListener:d,removeAllListeners:e}}},{}],12:[function(a,b,c){"use strict";b.exports=function(a){function b(){}var c={log:b,warn:b,error:b};if(!a&&window.console){var d=function(a,b){a[b]=function(){var a=console[b];if(a.apply)a.apply(console,arguments);else for(var c=0;c<arguments.length;c++)a(arguments[c])}};d(c,"log"),d(c,"warn"),d(c,"error")}return c}},{}],13:[function(a,b,c){"use strict";function d(a){return a[g]={},e(a)}function e(a){return a[g]}function f(a){delete a[g]}var g="_erd";b.exports={initState:d,getState:e,cleanState:f}},{}]},{},[7])(7)});
{
"name": "element-resize-detector",
"version": "1.1.11",
"version": "1.1.12",
"description": "Resize event emitter for elements.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/wnr/element-resize-detector",

# element-resize-detector
Super-optimized cross-browser resize listener for elements. Up to 37x faster than related approaches (read section 5 of the [article](http://arxiv.org/pdf/1511.01223v1.pdf)).
Optimized cross-browser resize listener for elements. Up to 37x faster than related approaches (read section 5 of the [article](http://arxiv.org/pdf/1511.01223v1.pdf)).

@@ -63,2 +63,4 @@ ```

## Credits
Big thanks to [Evry](https://www.evry.com/) sponsoring this project.
This library is using the two approaches (scroll and object) as first described at [http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/](http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/).

@@ -72,2 +74,7 @@

#### 1.1.12
* Fixed an issue with embedded WebView's on Android and iOS (when getComputedStyle.width = null). See #74.
* Fixed an issue with unrendered iframe in FireFox. See #68.
#### 1.1.11

@@ -74,0 +81,0 @@

@@ -167,3 +167,13 @@ /**

}
return !isInDocument(element);
if (!isInDocument(element)) {
return true;
}
// FireFox returns null style in hidden iframes. See https://github.com/wnr/element-resize-detector/issues/68 and https://bugzilla.mozilla.org/show_bug.cgi?id=795520
if (getComputedStyle(element) === null) {
return true;
}
return false;
}

@@ -174,3 +184,4 @@

var container = getState(element).container.childNodes[0];
return getComputedStyle(container).width.indexOf("px") === -1; //Can only compute pixel value when rendered.
var style = getComputedStyle(container);
return !style.width || style.width.indexOf("px") === -1; //Can only compute pixel value when rendered.
}

@@ -177,0 +188,0 @@

Sorry, the diff of this file is too big to display

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